<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998

-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-8"></span><span class="hs-pragma">{-# LANGUAGE FlexibleContexts #-}</span><span>
</span><span id="line-9"></span><span class="hs-pragma">{-# LANGUAGE TypeFamilies #-}</span><span>
</span><span id="line-10"></span><span>
</span><span id="line-11"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns   #-}</span><span>
</span><span id="line-12"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}</span><span>
</span><span id="line-13"></span><span>
</span><span id="line-14"></span><span class="hs-comment">-- | Typechecking instance declarations</span><span>
</span><span id="line-15"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Tc.TyCl.Instance</span><span>
</span><span id="line-16"></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcInstDecls1"><span class="hs-identifier">tcInstDecls1</span></a></span><span>
</span><span id="line-17"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcInstDeclsDeriv"><span class="hs-identifier">tcInstDeclsDeriv</span></a></span><span>
</span><span id="line-18"></span><span>   </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcInstDecls2"><span class="hs-identifier">tcInstDecls2</span></a></span><span>
</span><span id="line-19"></span><span>   </span><span class="hs-special">)</span><span>
</span><span id="line-20"></span><span class="hs-keyword">where</span><span class="hs-cpp">

#include &quot;HsVersions.h&quot;
</span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Hs.html"><span class="hs-identifier">GHC.Hs</span></a></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Bind.html"><span class="hs-identifier">GHC.Tc.Gen.Bind</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.html"><span class="hs-identifier">GHC.Tc.TyCl</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html"><span class="hs-identifier">GHC.Tc.TyCl.Utils</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Utils.html#addTyConsToGblEnv"><span class="hs-identifier">addTyConsToGblEnv</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Class.html"><span class="hs-identifier">GHC.Tc.TyCl.Class</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Class.html#tcClassDecl2"><span class="hs-identifier">tcClassDecl2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Class.html#tcATDefault"><span class="hs-identifier">tcATDefault</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-31"></span><span>                           </span><span class="annot"><a href="GHC.Tc.TyCl.Class.html#HsSigFun"><span class="hs-identifier">HsSigFun</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Class.html#mkHsSigFun"><span class="hs-identifier">mkHsSigFun</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Class.html#badMethodErr"><span class="hs-identifier">badMethodErr</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-32"></span><span>                           </span><span class="annot"><a href="GHC.Tc.TyCl.Class.html#findMethodBind"><span class="hs-identifier">findMethodBind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Class.html#instantiateMethod"><span class="hs-identifier">instantiateMethod</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Sig.html"><span class="hs-identifier">GHC.Tc.Gen.Sig</span></a></span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Validity.html"><span class="hs-identifier">GHC.Tc.Validity</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Zonk.html"><span class="hs-identifier">GHC.Tc.Utils.Zonk</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcMType.html"><span class="hs-identifier">GHC.Tc.Utils.TcMType</span></a></span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html"><span class="hs-identifier">GHC.Tc.Types.Constraint</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html"><span class="hs-identifier">GHC.Tc.Types.Origin</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Build.html"><span class="hs-identifier">GHC.Tc.TyCl.Build</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html"><span class="hs-identifier">GHC.Tc.Utils.Instantiate</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.Class.html"><span class="hs-identifier">GHC.Tc.Instance.Class</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.Class.html#AssocInstInfo"><span class="hs-identifier">AssocInstInfo</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.Class.html#isNotAssociated"><span class="hs-identifier">isNotAssociated</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html"><span class="hs-identifier">GHC.Core.InstEnv</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.Family.html"><span class="hs-identifier">GHC.Tc.Instance.Family</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html"><span class="hs-identifier">GHC.Core.FamInstEnv</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.html"><span class="hs-identifier">GHC.Tc.Deriv</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html"><span class="hs-identifier">GHC.Tc.Utils.Env</span></a></span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.HsType.html"><span class="hs-identifier">GHC.Tc.Gen.HsType</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Unify.html"><span class="hs-identifier">GHC.Tc.Utils.Unify</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.html"><span class="hs-identifier">GHC.Core</span></a></span><span>        </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.html#Expr"><span class="hs-identifier">Expr</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#mkApps"><span class="hs-identifier">mkApps</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#mkVarApps"><span class="hs-identifier">mkVarApps</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.html#mkLams"><span class="hs-identifier">mkLams</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Make.html"><span class="hs-identifier">GHC.Core.Make</span></a></span><span>   </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Make.html#nO_METHOD_BINDING_ERROR_ID"><span class="hs-identifier">nO_METHOD_BINDING_ERROR_ID</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Unfold.html"><span class="hs-identifier">GHC.Core.Unfold</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Unfold.html#mkInlineUnfoldingWithArity"><span class="hs-identifier">mkInlineUnfoldingWithArity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.Unfold.html#mkDFunUnfolding"><span class="hs-identifier">mkDFunUnfolding</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html"><span class="hs-identifier">GHC.Core.Predicate</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Core.Predicate.html#classMethodInstTy"><span class="hs-identifier">classMethodInstTy</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html"><span class="hs-identifier">GHC.Tc.Types.Evidence</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Coercion.Axiom.html"><span class="hs-identifier">GHC.Core.Coercion.Axiom</span></a></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.ConLike.html"><span class="hs-identifier">GHC.Core.ConLike</span></a></span><span>
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Class.html"><span class="hs-identifier">GHC.Core.Class</span></a></span><span>
</span><span id="line-63"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.html"><span class="hs-identifier">GHC.Types.Var</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Var</span></span><span>
</span><span id="line-64"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html"><span class="hs-identifier">GHC.Types.Var.Env</span></a></span><span>
</span><span id="line-65"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-66"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-67"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-68"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-69"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>
</span><span id="line-70"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.FastString.html"><span class="hs-identifier">GHC.Data.FastString</span></a></span><span>
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Id.html"><span class="hs-identifier">GHC.Types.Id</span></a></span><span>
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.List.SetOps.html"><span class="hs-identifier">GHC.Data.List.SetOps</span></a></span><span>
</span><span id="line-73"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-74"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.Set.html"><span class="hs-identifier">GHC.Types.Name.Set</span></a></span><span>
</span><span id="line-75"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-76"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html"><span class="hs-identifier">GHC.Types.SrcLoc</span></a></span><span>
</span><span id="line-77"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-78"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.BooleanFormula.html"><span class="hs-identifier">GHC.Data.BooleanFormula</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.Data.BooleanFormula.html#isUnsatisfied"><span class="hs-identifier">isUnsatisfied</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.BooleanFormula.html#pprBooleanFormulaNice"><span class="hs-identifier">pprBooleanFormulaNice</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-79"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.LanguageExtensions.html#"><span class="hs-identifier">GHC.LanguageExtensions</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LangExt</span></span><span>
</span><span id="line-80"></span><span>
</span><span id="line-81"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-82"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Tuple.html#"><span class="hs-identifier">Data.Tuple</span></a></span><span>
</span><span id="line-83"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Maybe.html"><span class="hs-identifier">GHC.Data.Maybe</span></a></span><span>
</span><span id="line-84"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier">mapAccumL</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span>
</span><span id="line-86"></span><span>
</span><span id="line-87"></span><span class="hs-comment">{-
Typechecking instance declarations is done in two passes. The first
pass, made by @tcInstDecls1@, collects information to be used in the
second pass.

This pre-processed info includes the as-yet-unprocessed bindings
inside the instance declaration.  These are type-checked in the second
pass, when the class-instance envs and GVE contain all the info from
all the instance and value decls.  Indeed that's the reason we need
two passes over the instance decls.


Note [How instance declarations are translated]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here is how we translate instance declarations into Core

Running example:
        class C a where
           op1, op2 :: Ix b =&gt; a -&gt; b -&gt; b
           op2 = &lt;dm-rhs&gt;

        instance C a =&gt; C [a]
           {-# INLINE [2] op1 #-}
           op1 = &lt;rhs&gt;
===&gt;
        -- Method selectors
        op1,op2 :: forall a. C a =&gt; forall b. Ix b =&gt; a -&gt; b -&gt; b
        op1 = ...
        op2 = ...

        -- Default methods get the 'self' dictionary as argument
        -- so they can call other methods at the same type
        -- Default methods get the same type as their method selector
        $dmop2 :: forall a. C a =&gt; forall b. Ix b =&gt; a -&gt; b -&gt; b
        $dmop2 = /\a. \(d:C a). /\b. \(d2: Ix b). &lt;dm-rhs&gt;
               -- NB: type variables 'a' and 'b' are *both* in scope in &lt;dm-rhs&gt;
               -- Note [Tricky type variable scoping]

        -- A top-level definition for each instance method
        -- Here op1_i, op2_i are the &quot;instance method Ids&quot;
        -- The INLINE pragma comes from the user pragma
        {-# INLINE [2] op1_i #-}  -- From the instance decl bindings
        op1_i, op2_i :: forall a. C a =&gt; forall b. Ix b =&gt; [a] -&gt; b -&gt; b
        op1_i = /\a. \(d:C a).
               let this :: C [a]
                   this = df_i a d
                     -- Note [Subtle interaction of recursion and overlap]

                   local_op1 :: forall b. Ix b =&gt; [a] -&gt; b -&gt; b
                   local_op1 = &lt;rhs&gt;
                     -- Source code; run the type checker on this
                     -- NB: Type variable 'a' (but not 'b') is in scope in &lt;rhs&gt;
                     -- Note [Tricky type variable scoping]

               in local_op1 a d

        op2_i = /\a \d:C a. $dmop2 [a] (df_i a d)

        -- The dictionary function itself
        {-# NOINLINE CONLIKE df_i #-}   -- Never inline dictionary functions
        df_i :: forall a. C a -&gt; C [a]
        df_i = /\a. \d:C a. MkC (op1_i a d) (op2_i a d)
                -- But see Note [Default methods in instances]
                -- We can't apply the type checker to the default-method call

        -- Use a RULE to short-circuit applications of the class ops
        {-# RULE &quot;op1@C[a]&quot; forall a, d:C a.
                            op1 [a] (df_i d) = op1_i a d #-}

Note [Instances and loop breakers]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Note that df_i may be mutually recursive with both op1_i and op2_i.
  It's crucial that df_i is not chosen as the loop breaker, even
  though op1_i has a (user-specified) INLINE pragma.

* Instead the idea is to inline df_i into op1_i, which may then select
  methods from the MkC record, and thereby break the recursion with
  df_i, leaving a *self*-recursive op1_i.  (If op1_i doesn't call op at
  the same type, it won't mention df_i, so there won't be recursion in
  the first place.)

* If op1_i is marked INLINE by the user there's a danger that we won't
  inline df_i in it, and that in turn means that (since it'll be a
  loop-breaker because df_i isn't), op1_i will ironically never be
  inlined.  But this is OK: the recursion breaking happens by way of
  a RULE (the magic ClassOp rule above), and RULES work inside InlineRule
  unfoldings. See Note [RULEs enabled in InitialPhase] in GHC.Core.Opt.Simplify.Utils

Note [ClassOp/DFun selection]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
One thing we see a lot is stuff like
    op2 (df d1 d2)
where 'op2' is a ClassOp and 'df' is DFun.  Now, we could inline *both*
'op2' and 'df' to get
     case (MkD ($cop1 d1 d2) ($cop2 d1 d2) ... of
       MkD _ op2 _ _ _ -&gt; op2
And that will reduce to ($cop2 d1 d2) which is what we wanted.

But it's tricky to make this work in practice, because it requires us to
inline both 'op2' and 'df'.  But neither is keen to inline without having
seen the other's result; and it's very easy to get code bloat (from the
big intermediate) if you inline a bit too much.

Instead we use a cunning trick.
 * We arrange that 'df' and 'op2' NEVER inline.

 * We arrange that 'df' is ALWAYS defined in the sylised form
      df d1 d2 = MkD ($cop1 d1 d2) ($cop2 d1 d2) ...

 * We give 'df' a magical unfolding (DFunUnfolding [$cop1, $cop2, ..])
   that lists its methods.

 * We make GHC.Core.Unfold.exprIsConApp_maybe spot a DFunUnfolding and return
   a suitable constructor application -- inlining df &quot;on the fly&quot; as it
   were.

 * ClassOp rules: We give the ClassOp 'op2' a BuiltinRule that
   extracts the right piece iff its argument satisfies
   exprIsConApp_maybe.  This is done in GHC.Types.Id.Make.mkDictSelId

 * We make 'df' CONLIKE, so that shared uses still match; eg
      let d = df d1 d2
      in ...(op2 d)...(op1 d)...

Note [Single-method classes]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If the class has just one method (or, more accurately, just one element
of {superclasses + methods}), then we use a different strategy.

   class C a where op :: a -&gt; a
   instance C a =&gt; C [a] where op = &lt;blah&gt;

We translate the class decl into a newtype, which just gives a
top-level axiom. The &quot;constructor&quot; MkC expands to a cast, as does the
class-op selector.

   axiom Co:C a :: C a ~ (a-&gt;a)

   op :: forall a. C a -&gt; (a -&gt; a)
   op a d = d |&gt; (Co:C a)

   MkC :: forall a. (a-&gt;a) -&gt; C a
   MkC = /\a.\op. op |&gt; (sym Co:C a)

The clever RULE stuff doesn't work now, because ($df a d) isn't
a constructor application, so exprIsConApp_maybe won't return
Just &lt;blah&gt;.

Instead, we simply rely on the fact that casts are cheap:

   $df :: forall a. C a =&gt; C [a]
   {-# INLINE df #-}  -- NB: INLINE this
   $df = /\a. \d. MkC [a] ($cop_list a d)
       = $cop_list |&gt; forall a. C a -&gt; (sym (Co:C [a]))

   $cop_list :: forall a. C a =&gt; [a] -&gt; [a]
   $cop_list = &lt;blah&gt;

So if we see
   (op ($df a d))
we'll inline 'op' and '$df', since both are simply casts, and
good things happen.

Why do we use this different strategy?  Because otherwise we
end up with non-inlined dictionaries that look like
    $df = $cop |&gt; blah
which adds an extra indirection to every use, which seems stupid.  See
#4138 for an example (although the regression reported there
wasn't due to the indirection).

There is an awkward wrinkle though: we want to be very
careful when we have
    instance C a =&gt; C [a] where
      {-# INLINE op #-}
      op = ...
then we'll get an INLINE pragma on $cop_list but it's important that
$cop_list only inlines when it's applied to *two* arguments (the
dictionary and the list argument).  So we must not eta-expand $df
above.  We ensure that this doesn't happen by putting an INLINE
pragma on the dfun itself; after all, it ends up being just a cast.

There is one more dark corner to the INLINE story, even more deeply
buried.  Consider this (#3772):

    class DeepSeq a =&gt; C a where
      gen :: Int -&gt; a

    instance C a =&gt; C [a] where
      gen n = ...

    class DeepSeq a where
      deepSeq :: a -&gt; b -&gt; b

    instance DeepSeq a =&gt; DeepSeq [a] where
      {-# INLINE deepSeq #-}
      deepSeq xs b = foldr deepSeq b xs

That gives rise to these defns:

    $cdeepSeq :: DeepSeq a -&gt; [a] -&gt; b -&gt; b
    -- User INLINE( 3 args )!
    $cdeepSeq a (d:DS a) b (x:[a]) (y:b) = ...

    $fDeepSeq[] :: DeepSeq a -&gt; DeepSeq [a]
    -- DFun (with auto INLINE pragma)
    $fDeepSeq[] a d = $cdeepSeq a d |&gt; blah

    $cp1 a d :: C a =&gt; DeepSep [a]
    -- We don't want to eta-expand this, lest
    -- $cdeepSeq gets inlined in it!
    $cp1 a d = $fDeepSep[] a (scsel a d)

    $fC[] :: C a =&gt; C [a]
    -- Ordinary DFun
    $fC[] a d = MkC ($cp1 a d) ($cgen a d)

Here $cp1 is the code that generates the superclass for C [a].  The
issue is this: we must not eta-expand $cp1 either, or else $fDeepSeq[]
and then $cdeepSeq will inline there, which is definitely wrong.  Like
on the dfun, we solve this by adding an INLINE pragma to $cp1.

Note [Subtle interaction of recursion and overlap]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this
  class C a where { op1,op2 :: a -&gt; a }
  instance C a =&gt; C [a] where
    op1 x = op2 x ++ op2 x
    op2 x = ...
  instance C [Int] where
    ...

When type-checking the C [a] instance, we need a C [a] dictionary (for
the call of op2).  If we look up in the instance environment, we find
an overlap.  And in *general* the right thing is to complain (see Note
[Overlapping instances] in GHC.Core.InstEnv).  But in *this* case it's wrong to
complain, because we just want to delegate to the op2 of this same
instance.

Why is this justified?  Because we generate a (C [a]) constraint in
a context in which 'a' cannot be instantiated to anything that matches
other overlapping instances, or else we would not be executing this
version of op1 in the first place.

It might even be a bit disguised:

  nullFail :: C [a] =&gt; [a] -&gt; [a]
  nullFail x = op2 x ++ op2 x

  instance C a =&gt; C [a] where
    op1 x = nullFail x

Precisely this is used in package 'regex-base', module Context.hs.
See the overlapping instances for RegexContext, and the fact that they
call 'nullFail' just like the example above.  The DoCon package also
does the same thing; it shows up in module Fraction.hs.

Conclusion: when typechecking the methods in a C [a] instance, we want to
treat the 'a' as an *existential* type variable, in the sense described
by Note [Binding when looking up instances].  That is why isOverlappableTyVar
responds True to an InstSkol, which is the kind of skolem we use in
tcInstDecl2.


Note [Tricky type variable scoping]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In our example
        class C a where
           op1, op2 :: Ix b =&gt; a -&gt; b -&gt; b
           op2 = &lt;dm-rhs&gt;

        instance C a =&gt; C [a]
           {-# INLINE [2] op1 #-}
           op1 = &lt;rhs&gt;

note that 'a' and 'b' are *both* in scope in &lt;dm-rhs&gt;, but only 'a' is
in scope in &lt;rhs&gt;.  In particular, we must make sure that 'b' is in
scope when typechecking &lt;dm-rhs&gt;.  This is achieved by subFunTys,
which brings appropriate tyvars into scope. This happens for both
&lt;dm-rhs&gt; and for &lt;rhs&gt;, but that doesn't matter: the *renamer* will have
complained if 'b' is mentioned in &lt;rhs&gt;.



************************************************************************
*                                                                      *
\subsection{Extracting instance decls}
*                                                                      *
************************************************************************

Gather up the instance declarations from their various sources
-}</span><span>
</span><span id="line-378"></span><span>
</span><span id="line-379"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcInstDecls1"><span class="hs-identifier hs-type">tcInstDecls1</span></a></span><span>    </span><span class="hs-comment">-- Deal with both source-code and imported instance decls</span><span>
</span><span id="line-380"></span><span>   </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LInstDecl"><span class="hs-identifier hs-type">LInstDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span>         </span><span class="hs-comment">-- Source code instance decls</span><span>
</span><span id="line-381"></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.html#TcGblEnv"><span class="hs-identifier hs-type">TcGblEnv</span></a></span><span class="hs-special">,</span><span>            </span><span class="hs-comment">-- The full inst env</span><span>
</span><span id="line-382"></span><span>           </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span>    </span><span class="hs-comment">-- Source-code instance decls to process;</span><span>
</span><span id="line-383"></span><span>                                </span><span class="hs-comment">-- contains all dfuns for this module</span><span>
</span><span id="line-384"></span><span>           </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Deriv.html#DerivInfo"><span class="hs-identifier hs-type">DerivInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>         </span><span class="hs-comment">-- From data family instances</span><span>
</span><span id="line-385"></span><span>
</span><span id="line-386"></span><span id="tcInstDecls1"><span class="annot"><span class="annottext">tcInstDecls1 :: [LInstDecl (GhcPass 'Renamed)]
-&gt; TcM (TcGblEnv, [InstInfo (GhcPass 'Renamed)], [DerivInfo])
</span><a href="GHC.Tc.TyCl.Instance.html#tcInstDecls1"><span class="hs-identifier hs-var hs-var">tcInstDecls1</span></a></span></span><span> </span><span id="local-6989586621681163516"><span class="annot"><span class="annottext">[LInstDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163516"><span class="hs-identifier hs-var">inst_decls</span></a></span></span><span>
</span><span id="line-387"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>    </span><span class="hs-comment">-- Do class and family instance declarations</span><span>
</span><span id="line-388"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163515"><span class="annot"><span class="annottext">[([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])]
</span><a href="#local-6989586621681163515"><span class="hs-identifier hs-var">stuff</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(LInstDecl (GhcPass 'Renamed)
 -&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo]))
-&gt; [LInstDecl (GhcPass 'Renamed)]
-&gt; TcRn [([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])]
forall a b. (a -&gt; TcRn b) -&gt; [a] -&gt; TcRn [b]
</span><a href="GHC.Tc.Utils.Monad.html#mapAndRecoverM"><span class="hs-identifier hs-var">mapAndRecoverM</span></a></span><span> </span><span class="annot"><span class="annottext">LInstDecl (GhcPass 'Renamed)
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
</span><a href="GHC.Tc.TyCl.Instance.html#tcLocalInstDecl"><span class="hs-identifier hs-var">tcLocalInstDecl</span></a></span><span> </span><span class="annot"><span class="annottext">[LInstDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163516"><span class="hs-identifier hs-var">inst_decls</span></a></span><span>
</span><span id="line-389"></span><span>
</span><span id="line-390"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163512"><span class="annot"><span class="annottext">[[InstInfo (GhcPass 'Renamed)]]
</span><a href="#local-6989586621681163512"><span class="hs-identifier hs-var">local_infos_s</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163511"><span class="annot"><span class="annottext">[[FamInst]]
</span><a href="#local-6989586621681163511"><span class="hs-identifier hs-var">fam_insts_s</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163510"><span class="annot"><span class="annottext">[[DerivInfo]]
</span><a href="#local-6989586621681163510"><span class="hs-identifier hs-var">datafam_deriv_infos</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])]
-&gt; ([[InstInfo (GhcPass 'Renamed)]], [[FamInst]], [[DerivInfo]])
forall a b c. [(a, b, c)] -&gt; ([a], [b], [c])
</span><a href="../../base/src/GHC.List.html#unzip3"><span class="hs-identifier hs-var">unzip3</span></a></span><span> </span><span class="annot"><span class="annottext">[([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])]
</span><a href="#local-6989586621681163515"><span class="hs-identifier hs-var">stuff</span></a></span><span>
</span><span id="line-391"></span><span>             </span><span id="local-6989586621681163508"><span class="annot"><span class="annottext">fam_insts :: [FamInst]
</span><a href="#local-6989586621681163508"><span class="hs-identifier hs-var hs-var">fam_insts</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[[FamInst]] -&gt; [FamInst]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="annot"><span class="annottext">[[FamInst]]
</span><a href="#local-6989586621681163511"><span class="hs-identifier hs-var">fam_insts_s</span></a></span><span>
</span><span id="line-392"></span><span>             </span><span id="local-6989586621681163506"><span class="annot"><span class="annottext">local_infos :: [InstInfo (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163506"><span class="hs-identifier hs-var hs-var">local_infos</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[[InstInfo (GhcPass 'Renamed)]] -&gt; [InstInfo (GhcPass 'Renamed)]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="annot"><span class="annottext">[[InstInfo (GhcPass 'Renamed)]]
</span><a href="#local-6989586621681163512"><span class="hs-identifier hs-var">local_infos_s</span></a></span><span>
</span><span id="line-393"></span><span>
</span><span id="line-394"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163505"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681163505"><span class="hs-identifier hs-var">gbl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[InstInfo (GhcPass 'Renamed)] -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall a. [InstInfo (GhcPass 'Renamed)] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.TyCl.Instance.html#addClsInsts"><span class="hs-identifier hs-var">addClsInsts</span></a></span><span> </span><span class="annot"><span class="annottext">[InstInfo (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163506"><span class="hs-identifier hs-var">local_infos</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM TcGblEnv -&gt; TcM TcGblEnv) -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-395"></span><span>                    </span><span class="annot"><span class="annottext">[FamInst] -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall a. [FamInst] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.TyCl.Instance.html#addFamInsts"><span class="hs-identifier hs-var">addFamInsts</span></a></span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163508"><span class="hs-identifier hs-var">fam_insts</span></a></span><span>   </span><span class="annot"><span class="annottext">(TcM TcGblEnv -&gt; TcM TcGblEnv) -&gt; TcM TcGblEnv -&gt; TcM TcGblEnv
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-396"></span><span>                    </span><span class="annot"><span class="annottext">TcM TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-397"></span><span>
</span><span id="line-398"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcGblEnv, [InstInfo (GhcPass 'Renamed)], [DerivInfo])
-&gt; TcM (TcGblEnv, [InstInfo (GhcPass 'Renamed)], [DerivInfo])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681163505"><span class="hs-identifier hs-var">gbl_env</span></a></span><span>
</span><span id="line-399"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[InstInfo (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163506"><span class="hs-identifier hs-var">local_infos</span></a></span><span>
</span><span id="line-400"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[[DerivInfo]] -&gt; [DerivInfo]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="annot"><span class="annottext">[[DerivInfo]]
</span><a href="#local-6989586621681163510"><span class="hs-identifier hs-var">datafam_deriv_infos</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-401"></span><span>
</span><span id="line-402"></span><span class="hs-comment">-- | Use DerivInfo for data family instances (produced by tcInstDecls1),</span><span>
</span><span id="line-403"></span><span class="hs-comment">--   datatype declarations (TyClDecl), and standalone deriving declarations</span><span>
</span><span id="line-404"></span><span class="hs-comment">--   (DerivDecl) to check and process all derived class instances.</span><span>
</span><span id="line-405"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcInstDeclsDeriv"><span class="hs-identifier hs-type">tcInstDeclsDeriv</span></a></span><span>
</span><span id="line-406"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Deriv.html#DerivInfo"><span class="hs-identifier hs-type">DerivInfo</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-407"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LDerivDecl"><span class="hs-identifier hs-type">LDerivDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-408"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.html#TcGblEnv"><span class="hs-identifier hs-type">TcGblEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#HsValBinds"><span class="hs-identifier hs-type">HsValBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-409"></span><span id="tcInstDeclsDeriv"><span class="annot"><span class="annottext">tcInstDeclsDeriv :: [DerivInfo]
-&gt; [LDerivDecl (GhcPass 'Renamed)]
-&gt; TcM
     (TcGblEnv, [InstInfo (GhcPass 'Renamed)],
      HsValBinds (GhcPass 'Renamed))
</span><a href="GHC.Tc.TyCl.Instance.html#tcInstDeclsDeriv"><span class="hs-identifier hs-var hs-var">tcInstDeclsDeriv</span></a></span></span><span> </span><span id="local-6989586621681163501"><span class="annot"><span class="annottext">[DerivInfo]
</span><a href="#local-6989586621681163501"><span class="hs-identifier hs-var">deriv_infos</span></a></span></span><span> </span><span id="local-6989586621681163500"><span class="annot"><span class="annottext">[LDerivDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163500"><span class="hs-identifier hs-var">derivds</span></a></span></span><span>
</span><span id="line-410"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span id="local-6989586621681163499"><span class="annot"><span class="annottext">ThStage
</span><a href="#local-6989586621681163499"><span class="hs-identifier hs-var">th_stage</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM ThStage
</span><a href="GHC.Tc.Utils.Monad.html#getStage"><span class="hs-identifier hs-var">getStage</span></a></span><span> </span><span class="hs-comment">-- See Note [Deriving inside TH brackets]</span><span>
</span><span id="line-411"></span><span>       </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">ThStage -&gt; Bool
</span><a href="GHC.Tc.Utils.Env.html#isBrackStage"><span class="hs-identifier hs-var">isBrackStage</span></a></span><span> </span><span class="annot"><span class="annottext">ThStage
</span><a href="#local-6989586621681163499"><span class="hs-identifier hs-var">th_stage</span></a></span><span>
</span><span id="line-412"></span><span>       </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681163496"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681163496"><span class="hs-identifier hs-var">gbl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-413"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcGblEnv, [InstInfo (GhcPass 'Renamed)],
 HsValBinds (GhcPass 'Renamed))
-&gt; TcM
     (TcGblEnv, [InstInfo (GhcPass 'Renamed)],
      HsValBinds (GhcPass 'Renamed))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681163496"><span class="hs-identifier hs-var">gbl_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag (InstInfo (GhcPass 'Renamed)) -&gt; [InstInfo (GhcPass 'Renamed)]
forall a. Bag a -&gt; [a]
</span><a href="GHC.Data.Bag.html#bagToList"><span class="hs-identifier hs-var">bagToList</span></a></span><span> </span><span class="annot"><span class="annottext">Bag (InstInfo (GhcPass 'Renamed))
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HsValBinds (GhcPass 'Renamed)
forall (a :: Pass) (b :: Pass).
HsValBindsLR (GhcPass a) (GhcPass b)
</span><a href="GHC.Hs.Binds.html#emptyValBindsOut"><span class="hs-identifier hs-var">emptyValBindsOut</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-414"></span><span>       </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163492"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681163492"><span class="hs-identifier hs-var">tcg_env</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163491"><span class="annot"><span class="annottext">Bag (InstInfo (GhcPass 'Renamed))
</span><a href="#local-6989586621681163491"><span class="hs-identifier hs-var">info_bag</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163490"><span class="annot"><span class="annottext">HsValBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681163490"><span class="hs-identifier hs-var">valbinds</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[DerivInfo]
-&gt; [LDerivDecl (GhcPass 'Renamed)]
-&gt; TcM
     (TcGblEnv, Bag (InstInfo (GhcPass 'Renamed)),
      HsValBinds (GhcPass 'Renamed))
</span><a href="GHC.Tc.Deriv.html#tcDeriving"><span class="hs-identifier hs-var">tcDeriving</span></a></span><span> </span><span class="annot"><span class="annottext">[DerivInfo]
</span><a href="#local-6989586621681163501"><span class="hs-identifier hs-var">deriv_infos</span></a></span><span> </span><span class="annot"><span class="annottext">[LDerivDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163500"><span class="hs-identifier hs-var">derivds</span></a></span><span>
</span><span id="line-415"></span><span>               </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TcGblEnv, [InstInfo (GhcPass 'Renamed)],
 HsValBinds (GhcPass 'Renamed))
-&gt; TcM
     (TcGblEnv, [InstInfo (GhcPass 'Renamed)],
      HsValBinds (GhcPass 'Renamed))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681163492"><span class="hs-identifier hs-var">tcg_env</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag (InstInfo (GhcPass 'Renamed)) -&gt; [InstInfo (GhcPass 'Renamed)]
forall a. Bag a -&gt; [a]
</span><a href="GHC.Data.Bag.html#bagToList"><span class="hs-identifier hs-var">bagToList</span></a></span><span> </span><span class="annot"><span class="annottext">Bag (InstInfo (GhcPass 'Renamed))
</span><a href="#local-6989586621681163491"><span class="hs-identifier hs-var">info_bag</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HsValBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681163490"><span class="hs-identifier hs-var">valbinds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-416"></span><span>
</span><span id="line-417"></span><span id="local-6989586621681164223"><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#addClsInsts"><span class="hs-identifier hs-type">addClsInsts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681164223"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681164223"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-418"></span><span id="addClsInsts"><span class="annot"><span class="annottext">addClsInsts :: forall a. [InstInfo (GhcPass 'Renamed)] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.TyCl.Instance.html#addClsInsts"><span class="hs-identifier hs-var hs-var">addClsInsts</span></a></span></span><span> </span><span id="local-6989586621681163488"><span class="annot"><span class="annottext">[InstInfo (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163488"><span class="hs-identifier hs-var">infos</span></a></span></span><span> </span><span id="local-6989586621681163487"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681163487"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-419"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[ClsInst] -&gt; TcM a -&gt; TcM a
forall a. [ClsInst] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Instantiate.html#tcExtendLocalInstEnv"><span class="hs-identifier hs-var">tcExtendLocalInstEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstInfo (GhcPass 'Renamed) -&gt; ClsInst)
-&gt; [InstInfo (GhcPass 'Renamed)] -&gt; [ClsInst]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">InstInfo (GhcPass 'Renamed) -&gt; ClsInst
forall a. InstInfo a -&gt; ClsInst
</span><a href="GHC.Tc.Utils.Env.html#iSpec"><span class="hs-identifier hs-var hs-var">iSpec</span></a></span><span> </span><span class="annot"><span class="annottext">[InstInfo (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163488"><span class="hs-identifier hs-var">infos</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681163487"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span id="local-6989586621681164219"><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#addFamInsts"><span class="hs-identifier hs-type">addFamInsts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInst"><span class="hs-identifier hs-type">FamInst</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681164219"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681164219"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-422"></span><span class="hs-comment">-- Extend (a) the family instance envt</span><span>
</span><span id="line-423"></span><span class="hs-comment">--        (b) the type envt with stuff from data type decls</span><span>
</span><span id="line-424"></span><span id="addFamInsts"><span class="annot"><span class="annottext">addFamInsts :: forall a. [FamInst] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.TyCl.Instance.html#addFamInsts"><span class="hs-identifier hs-var hs-var">addFamInsts</span></a></span></span><span> </span><span id="local-6989586621681163482"><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163482"><span class="hs-identifier hs-var">fam_insts</span></a></span></span><span> </span><span id="local-6989586621681163481"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681163481"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-425"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[FamInst] -&gt; TcM a -&gt; TcM a
forall a. [FamInst] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Instance.Family.html#tcExtendLocalFamInstEnv"><span class="hs-identifier hs-var">tcExtendLocalFamInstEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163482"><span class="hs-identifier hs-var">fam_insts</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM a -&gt; TcM a) -&gt; TcM a -&gt; TcM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-426"></span><span>    </span><span class="annot"><span class="annottext">[TyThing] -&gt; TcM a -&gt; TcM a
forall r. [TyThing] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalEnv"><span class="hs-identifier hs-var">tcExtendGlobalEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[TyThing]
</span><a href="#local-6989586621681163478"><span class="hs-identifier hs-var">axioms</span></a></span><span>          </span><span class="annot"><span class="annottext">(TcM a -&gt; TcM a) -&gt; TcM a -&gt; TcM a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-427"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;addFamInsts&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[FamInst] -&gt; SDoc
</span><a href="GHC.Core.FamInstEnv.html#pprFamInsts"><span class="hs-identifier hs-var">pprFamInsts</span></a></span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163482"><span class="hs-identifier hs-var">fam_insts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-428"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163475"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681163475"><span class="hs-identifier hs-var">gbl_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TyCon] -&gt; TcM TcGblEnv
</span><a href="GHC.Tc.TyCl.Utils.html#addTyConsToGblEnv"><span class="hs-identifier hs-var">addTyConsToGblEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[TyCon]
</span><a href="#local-6989586621681163474"><span class="hs-identifier hs-var">data_rep_tycons</span></a></span><span>
</span><span id="line-429"></span><span>                    </span><span class="hs-comment">-- Does not add its axiom; that comes</span><span>
</span><span id="line-430"></span><span>                    </span><span class="hs-comment">-- from adding the 'axioms' above</span><span>
</span><span id="line-431"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcM a -&gt; TcM a
forall gbl lcl a. gbl -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#setGblEnv"><span class="hs-identifier hs-var">setGblEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681163475"><span class="hs-identifier hs-var">gbl_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681163481"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-432"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-433"></span><span>    </span><span id="local-6989586621681163478"><span class="annot"><span class="annottext">axioms :: [TyThing]
</span><a href="#local-6989586621681163478"><span class="hs-identifier hs-var hs-var">axioms</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(FamInst -&gt; TyThing) -&gt; [FamInst] -&gt; [TyThing]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CoAxiom Branched -&gt; TyThing
</span><a href="GHC.Core.TyCo.Rep.html#ACoAxiom"><span class="hs-identifier hs-var">ACoAxiom</span></a></span><span> </span><span class="annot"><span class="annottext">(CoAxiom Branched -&gt; TyThing)
-&gt; (FamInst -&gt; CoAxiom Branched) -&gt; FamInst -&gt; TyThing
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiom Unbranched -&gt; CoAxiom Branched
forall (br :: BranchFlag). CoAxiom br -&gt; CoAxiom Branched
</span><a href="GHC.Core.Coercion.Axiom.html#toBranchedAxiom"><span class="hs-identifier hs-var">toBranchedAxiom</span></a></span><span> </span><span class="annot"><span class="annottext">(CoAxiom Unbranched -&gt; CoAxiom Branched)
-&gt; (FamInst -&gt; CoAxiom Unbranched) -&gt; FamInst -&gt; CoAxiom Branched
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FamInst -&gt; CoAxiom Unbranched
</span><a href="GHC.Core.FamInstEnv.html#famInstAxiom"><span class="hs-identifier hs-var">famInstAxiom</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163482"><span class="hs-identifier hs-var">fam_insts</span></a></span><span>
</span><span id="line-434"></span><span>    </span><span id="local-6989586621681163474"><span class="annot"><span class="annottext">data_rep_tycons :: [TyCon]
</span><a href="#local-6989586621681163474"><span class="hs-identifier hs-var hs-var">data_rep_tycons</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[FamInst] -&gt; [TyCon]
</span><a href="GHC.Core.FamInstEnv.html#famInstsRepTyCons"><span class="hs-identifier hs-var">famInstsRepTyCons</span></a></span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163482"><span class="hs-identifier hs-var">fam_insts</span></a></span><span>
</span><span id="line-435"></span><span>      </span><span class="hs-comment">-- The representation tycons for 'data instances' declarations</span><span>
</span><span id="line-436"></span><span>
</span><span id="line-437"></span><span class="hs-comment">{-
Note [Deriving inside TH brackets]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Given a declaration bracket
  [d| data T = A | B deriving( Show ) |]

there is really no point in generating the derived code for deriving(
Show) and then type-checking it. This will happen at the call site
anyway, and the type check should never fail!  Moreover (#6005)
the scoping of the generated code inside the bracket does not seem to
work out.

The easy solution is simply not to generate the derived instances at
all.  (A less brutal solution would be to generate them with no
bindings.)  This will become moot when we shift to the new TH plan, so
the brutal solution will do.
-}</span><span>
</span><span id="line-454"></span><span>
</span><span id="line-455"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcLocalInstDecl"><span class="hs-identifier hs-type">tcLocalInstDecl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#LInstDecl"><span class="hs-identifier hs-type">LInstDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span>
</span><span id="line-456"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInst"><span class="hs-identifier hs-type">FamInst</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Deriv.html#DerivInfo"><span class="hs-identifier hs-type">DerivInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-457"></span><span>        </span><span class="hs-comment">-- A source-file instance declaration</span><span>
</span><span id="line-458"></span><span>        </span><span class="hs-comment">-- Type-check all the stuff before the &quot;where&quot;</span><span>
</span><span id="line-459"></span><span>        </span><span class="hs-comment">--</span><span>
</span><span id="line-460"></span><span>        </span><span class="hs-comment">-- We check for respectable instance type, and context</span><span>
</span><span id="line-461"></span><span id="tcLocalInstDecl"><span class="annot"><span class="annottext">tcLocalInstDecl :: LInstDecl (GhcPass 'Renamed)
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
</span><a href="GHC.Tc.TyCl.Instance.html#tcLocalInstDecl"><span class="hs-identifier hs-var hs-var">tcLocalInstDecl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681163466"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163466"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#TyFamInstD"><span class="hs-identifier hs-type">TyFamInstD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tfid_inst :: forall pass. InstDecl pass -&gt; TyFamInstDecl pass
</span><a href="GHC.Hs.Decls.html#tfid_inst"><span class="hs-identifier hs-var">tfid_inst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163463"><span class="annot"><span class="annottext">TyFamInstDecl (GhcPass 'Renamed)
</span><a href="#local-6989586621681163463"><span class="hs-identifier hs-var">decl</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-462"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681163462"><span class="annot"><span class="annottext">FamInst
</span><a href="#local-6989586621681163462"><span class="hs-identifier hs-var">fam_inst</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AssocInstInfo -&gt; LTyFamInstDecl (GhcPass 'Renamed) -&gt; TcM FamInst
</span><a href="GHC.Tc.TyCl.Instance.html#tcTyFamInstDecl"><span class="hs-identifier hs-var">tcTyFamInstDecl</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="GHC.Tc.Instance.Class.html#NotAssociated"><span class="hs-identifier hs-var">NotAssociated</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan
-&gt; TyFamInstDecl (GhcPass 'Renamed)
-&gt; LTyFamInstDecl (GhcPass 'Renamed)
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163466"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">TyFamInstDecl (GhcPass 'Renamed)
</span><a href="#local-6989586621681163463"><span class="hs-identifier hs-var">decl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-463"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">FamInst
</span><a href="#local-6989586621681163462"><span class="hs-identifier hs-var">fam_inst</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-464"></span><span>
</span><span id="line-465"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcLocalInstDecl"><span class="hs-identifier hs-var">tcLocalInstDecl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681163459"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163459"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#DataFamInstD"><span class="hs-identifier hs-type">DataFamInstD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dfid_inst :: forall pass. InstDecl pass -&gt; DataFamInstDecl pass
</span><a href="GHC.Hs.Decls.html#dfid_inst"><span class="hs-identifier hs-var">dfid_inst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163456"><span class="annot"><span class="annottext">DataFamInstDecl (GhcPass 'Renamed)
</span><a href="#local-6989586621681163456"><span class="hs-identifier hs-var">decl</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-466"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163455"><span class="annot"><span class="annottext">FamInst
</span><a href="#local-6989586621681163455"><span class="hs-identifier hs-var">fam_inst</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163454"><span class="annot"><span class="annottext">Maybe DerivInfo
</span><a href="#local-6989586621681163454"><span class="hs-identifier hs-var">m_deriv_info</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
-&gt; TyVarEnv Name
-&gt; LDataFamInstDecl (GhcPass 'Renamed)
-&gt; TcM (FamInst, Maybe DerivInfo)
</span><a href="GHC.Tc.TyCl.Instance.html#tcDataFamInstDecl"><span class="hs-identifier hs-var">tcDataFamInstDecl</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="GHC.Tc.Instance.Class.html#NotAssociated"><span class="hs-identifier hs-var">NotAssociated</span></a></span><span> </span><span class="annot"><span class="annottext">TyVarEnv Name
forall a. VarEnv a
</span><a href="GHC.Types.Var.Env.html#emptyVarEnv"><span class="hs-identifier hs-var">emptyVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan
-&gt; DataFamInstDecl (GhcPass 'Renamed)
-&gt; LDataFamInstDecl (GhcPass 'Renamed)
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163459"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">DataFamInstDecl (GhcPass 'Renamed)
</span><a href="#local-6989586621681163456"><span class="hs-identifier hs-var">decl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-467"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">FamInst
</span><a href="#local-6989586621681163455"><span class="hs-identifier hs-var">fam_inst</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe DerivInfo -&gt; [DerivInfo]
forall a. Maybe a -&gt; [a]
</span><a href="../../base/src/Data.Maybe.html#maybeToList"><span class="hs-identifier hs-var">maybeToList</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe DerivInfo
</span><a href="#local-6989586621681163454"><span class="hs-identifier hs-var">m_deriv_info</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-468"></span><span>
</span><span id="line-469"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcLocalInstDecl"><span class="hs-identifier hs-var">tcLocalInstDecl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681163450"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163450"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#ClsInstD"><span class="hs-identifier hs-type">ClsInstD</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cid_inst :: forall pass. InstDecl pass -&gt; ClsInstDecl pass
</span><a href="GHC.Hs.Decls.html#cid_inst"><span class="hs-identifier hs-var">cid_inst</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163447"><span class="annot"><span class="annottext">ClsInstDecl (GhcPass 'Renamed)
</span><a href="#local-6989586621681163447"><span class="hs-identifier hs-var">decl</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-470"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163446"><span class="annot"><span class="annottext">[InstInfo (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163446"><span class="hs-identifier hs-var">insts</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163445"><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163445"><span class="hs-identifier hs-var">fam_insts</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163444"><span class="annot"><span class="annottext">[DerivInfo]
</span><a href="#local-6989586621681163444"><span class="hs-identifier hs-var">deriv_infos</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LClsInstDecl (GhcPass 'Renamed)
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
</span><a href="GHC.Tc.TyCl.Instance.html#tcClsInstDecl"><span class="hs-identifier hs-var">tcClsInstDecl</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan
-&gt; ClsInstDecl (GhcPass 'Renamed)
-&gt; LClsInstDecl (GhcPass 'Renamed)
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163450"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInstDecl (GhcPass 'Renamed)
</span><a href="#local-6989586621681163447"><span class="hs-identifier hs-var">decl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-471"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[InstInfo (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163446"><span class="hs-identifier hs-var">insts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163445"><span class="hs-identifier hs-var">fam_insts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[DerivInfo]
</span><a href="#local-6989586621681163444"><span class="hs-identifier hs-var">deriv_infos</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-472"></span><span>
</span><span id="line-473"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcClsInstDecl"><span class="hs-identifier hs-type">tcClsInstDecl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#LClsInstDecl"><span class="hs-identifier hs-type">LClsInstDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span>
</span><span id="line-474"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInst"><span class="hs-identifier hs-type">FamInst</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Deriv.html#DerivInfo"><span class="hs-identifier hs-type">DerivInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-475"></span><span class="hs-comment">-- The returned DerivInfos are for any associated data families</span><span>
</span><span id="line-476"></span><span id="tcClsInstDecl"><span class="annot"><span class="annottext">tcClsInstDecl :: LClsInstDecl (GhcPass 'Renamed)
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
</span><a href="GHC.Tc.TyCl.Instance.html#tcClsInstDecl"><span class="hs-identifier hs-var hs-var">tcClsInstDecl</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681163442"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163442"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#ClsInstDecl"><span class="hs-identifier hs-type">ClsInstDecl</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">cid_poly_ty :: forall pass. ClsInstDecl pass -&gt; LHsSigType pass
</span><a href="GHC.Hs.Decls.html#cid_poly_ty"><span class="hs-identifier hs-var">cid_poly_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163439"><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681163439"><span class="hs-identifier hs-var">hs_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cid_binds :: forall pass. ClsInstDecl pass -&gt; LHsBinds pass
</span><a href="GHC.Hs.Decls.html#cid_binds"><span class="hs-identifier hs-var">cid_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163437"><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681163437"><span class="hs-identifier hs-var">binds</span></a></span></span><span>
</span><span id="line-477"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cid_sigs :: forall pass. ClsInstDecl pass -&gt; [LSig pass]
</span><a href="GHC.Hs.Decls.html#cid_sigs"><span class="hs-identifier hs-var">cid_sigs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163435"><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163435"><span class="hs-identifier hs-var">uprags</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cid_tyfam_insts :: forall pass. ClsInstDecl pass -&gt; [LTyFamInstDecl pass]
</span><a href="GHC.Hs.Decls.html#cid_tyfam_insts"><span class="hs-identifier hs-var">cid_tyfam_insts</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163433"><span class="annot"><span class="annottext">[LTyFamInstDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163433"><span class="hs-identifier hs-var">ats</span></a></span></span><span>
</span><span id="line-478"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cid_overlap_mode :: forall pass. ClsInstDecl pass -&gt; Maybe (Located OverlapMode)
</span><a href="GHC.Hs.Decls.html#cid_overlap_mode"><span class="hs-identifier hs-var">cid_overlap_mode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163431"><span class="annot"><span class="annottext">Maybe (Located OverlapMode)
</span><a href="#local-6989586621681163431"><span class="hs-identifier hs-var">overlap_mode</span></a></span></span><span>
</span><span id="line-479"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">cid_datafam_insts :: forall pass. ClsInstDecl pass -&gt; [LDataFamInstDecl pass]
</span><a href="GHC.Hs.Decls.html#cid_datafam_insts"><span class="hs-identifier hs-var">cid_datafam_insts</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163429"><span class="annot"><span class="annottext">[LDataFamInstDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163429"><span class="hs-identifier hs-var">adts</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-480"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
forall a. SrcSpan -&gt; TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#setSrcSpan"><span class="hs-identifier hs-var">setSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163442"><span class="hs-identifier hs-var">loc</span></a></span><span>                      </span><span class="annot"><span class="annottext">(TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
 -&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo]))
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-481"></span><span>    </span><span class="annot"><span class="annottext">SDoc
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
forall a. SDoc -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#addErrCtxt"><span class="hs-identifier hs-var">addErrCtxt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed) -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#instDeclCtxt1"><span class="hs-identifier hs-var">instDeclCtxt1</span></a></span><span> </span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681163439"><span class="hs-identifier hs-var">hs_ty</span></a></span><span class="hs-special">)</span><span>  </span><span class="annot"><span class="annottext">(TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
 -&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo]))
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-482"></span><span>    </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681163425"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163425"><span class="hs-identifier hs-var">dfun_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; LHsSigType (GhcPass 'Renamed) -&gt; TcM PredType
</span><a href="GHC.Tc.Gen.HsType.html#tcHsClsInstType"><span class="hs-identifier hs-var">tcHsClsInstType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#InstDeclCtxt"><span class="hs-identifier hs-var">InstDeclCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681163439"><span class="hs-identifier hs-var">hs_ty</span></a></span><span>
</span><span id="line-483"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163422"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163422"><span class="hs-identifier hs-var">tyvars</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163421"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163421"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163420"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163420"><span class="hs-identifier hs-var">clas</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163419"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163419"><span class="hs-identifier hs-var">inst_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; ([Id], [PredType], Class, [PredType])
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitDFunTy"><span class="hs-identifier hs-var">tcSplitDFunTy</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163425"><span class="hs-identifier hs-var">dfun_ty</span></a></span><span>
</span><span id="line-484"></span><span>             </span><span class="hs-comment">-- NB: tcHsClsInstType does checkValidInstance</span><span>
</span><span id="line-485"></span><span>
</span><span id="line-486"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163417"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681163417"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163416"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163416"><span class="hs-identifier hs-var">skol_tvs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; TcM (TCvSubst, [Id])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVars"><span class="hs-identifier hs-var">tcInstSkolTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163422"><span class="hs-identifier hs-var">tyvars</span></a></span><span>
</span><span id="line-487"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163414"><span class="annot"><span class="annottext">tv_skol_prs :: [(Name, Id)]
</span><a href="#local-6989586621681163414"><span class="hs-identifier hs-var hs-var">tv_skol_prs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Var.html#tyVarName"><span class="hs-identifier hs-var">tyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163412"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163411"><span class="hs-identifier hs-var">skol_tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-488"></span><span>                            </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163412"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163412"><span class="hs-identifier hs-var">tv</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163411"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163411"><span class="hs-identifier hs-var">skol_tv</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163422"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [(Id, Id)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163416"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-489"></span><span>              </span><span class="hs-comment">-- Map from the skolemized Names to the original Names.</span><span>
</span><span id="line-490"></span><span>              </span><span class="hs-comment">-- See Note [Associated data family instances and di_scoped_tvs].</span><span>
</span><span id="line-491"></span><span>              </span><span id="local-6989586621681163410"><span class="annot"><span class="annottext">tv_skol_env :: TyVarEnv Name
</span><a href="#local-6989586621681163410"><span class="hs-identifier hs-var hs-var">tv_skol_env</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Id, Name)] -&gt; TyVarEnv Name
forall a. [(Id, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#mkVarEnv"><span class="hs-identifier hs-var">mkVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">([(Id, Name)] -&gt; TyVarEnv Name) -&gt; [(Id, Name)] -&gt; TyVarEnv Name
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">((Name, Id) -&gt; (Id, Name)) -&gt; [(Name, Id)] -&gt; [(Id, Name)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(Name, Id) -&gt; (Id, Name)
forall a b. (a, b) -&gt; (b, a)
</span><a href="../../base/src/Data.Tuple.html#swap"><span class="hs-identifier hs-var">swap</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Id)]
</span><a href="#local-6989586621681163414"><span class="hs-identifier hs-var">tv_skol_prs</span></a></span><span>
</span><span id="line-492"></span><span>              </span><span id="local-6989586621681163407"><span class="annot"><span class="annottext">n_inferred :: ConTag
</span><a href="#local-6989586621681163407"><span class="hs-identifier hs-var hs-var">n_inferred</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarBndr Id ArgFlag -&gt; Bool) -&gt; [VarBndr Id ArgFlag] -&gt; ConTag
forall a. (a -&gt; Bool) -&gt; [a] -&gt; ConTag
</span><a href="GHC.Utils.Misc.html#countWhile"><span class="hs-identifier hs-var">countWhile</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">ArgFlag -&gt; ArgFlag -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><a href="GHC.Types.Var.html#Inferred"><span class="hs-identifier hs-var">Inferred</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(ArgFlag -&gt; Bool)
-&gt; (VarBndr Id ArgFlag -&gt; ArgFlag) -&gt; VarBndr Id ArgFlag -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">VarBndr Id ArgFlag -&gt; ArgFlag
forall tv argf. VarBndr tv argf -&gt; argf
</span><a href="GHC.Types.Var.html#binderArgFlag"><span class="hs-identifier hs-var">binderArgFlag</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([VarBndr Id ArgFlag] -&gt; ConTag) -&gt; [VarBndr Id ArgFlag] -&gt; ConTag
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-493"></span><span>                           </span><span class="annot"><span class="annottext">([VarBndr Id ArgFlag], PredType) -&gt; [VarBndr Id ArgFlag]
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">(([VarBndr Id ArgFlag], PredType) -&gt; [VarBndr Id ArgFlag])
-&gt; ([VarBndr Id ArgFlag], PredType) -&gt; [VarBndr Id ArgFlag]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; ([VarBndr Id ArgFlag], PredType)
</span><a href="GHC.Core.Type.html#splitForAllVarBndrs"><span class="hs-identifier hs-var">splitForAllVarBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163425"><span class="hs-identifier hs-var">dfun_ty</span></a></span><span>
</span><span id="line-494"></span><span>              </span><span id="local-6989586621681163402"><span class="annot"><span class="annottext">visible_skol_tvs :: [Id]
</span><a href="#local-6989586621681163402"><span class="hs-identifier hs-var hs-var">visible_skol_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConTag -&gt; [Id] -&gt; [Id]
forall a. ConTag -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#drop"><span class="hs-identifier hs-var">drop</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag
</span><a href="#local-6989586621681163407"><span class="hs-identifier hs-var">n_inferred</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163416"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span>
</span><span id="line-495"></span><span>
</span><span id="line-496"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcLocalInstDecl 1&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163425"><span class="hs-identifier hs-var">dfun_ty</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; ConTag
</span><a href="GHC.Core.Type.html#invisibleTyBndrCount"><span class="hs-identifier hs-var">invisibleTyBndrCount</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163425"><span class="hs-identifier hs-var">dfun_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163416"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-497"></span><span>
</span><span id="line-498"></span><span>        </span><span class="hs-comment">-- Next, process any associated types.</span><span>
</span><span id="line-499"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163397"><span class="annot"><span class="annottext">[(FamInst, Maybe DerivInfo)]
</span><a href="#local-6989586621681163397"><span class="hs-identifier hs-var">datafam_stuff</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163396"><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163396"><span class="hs-identifier hs-var">tyfam_insts</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-500"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(Name, Id)]
-&gt; TcM ([(FamInst, Maybe DerivInfo)], [FamInst])
-&gt; TcM ([(FamInst, Maybe DerivInfo)], [FamInst])
forall r. [(Name, Id)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendNameTyVarEnv"><span class="hs-identifier hs-var">tcExtendNameTyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[(Name, Id)]
</span><a href="#local-6989586621681163414"><span class="hs-identifier hs-var">tv_skol_prs</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM ([(FamInst, Maybe DerivInfo)], [FamInst])
 -&gt; TcM ([(FamInst, Maybe DerivInfo)], [FamInst]))
-&gt; TcM ([(FamInst, Maybe DerivInfo)], [FamInst])
-&gt; TcM ([(FamInst, Maybe DerivInfo)], [FamInst])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-501"></span><span>                </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163394"><span class="annot"><span class="annottext">mini_env :: VarEnv PredType
</span><a href="#local-6989586621681163394"><span class="hs-identifier hs-var hs-var">mini_env</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Id, PredType)] -&gt; VarEnv PredType
forall a. [(Id, a)] -&gt; VarEnv a
</span><a href="GHC.Types.Var.Env.html#mkVarEnv"><span class="hs-identifier hs-var">mkVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; [Id]
</span><a href="GHC.Core.Class.html#classTyVars"><span class="hs-identifier hs-var hs-var">classTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163420"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [PredType] -&gt; [(Id, PredType)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; [PredType] -&gt; [PredType]
TCvSubst -&gt; [PredType] -&gt; [PredType]
</span><a href="GHC.Core.TyCo.Subst.html#substTys"><span class="hs-identifier hs-var">substTys</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681163417"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163419"><span class="hs-identifier hs-var">inst_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-502"></span><span>                          </span><span id="local-6989586621681163391"><span class="annot"><span class="annottext">mini_subst :: TCvSubst
</span><a href="#local-6989586621681163391"><span class="hs-identifier hs-var hs-var">mini_subst</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InScopeSet -&gt; VarEnv PredType -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#mkTvSubst"><span class="hs-identifier hs-var">mkTvSubst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet -&gt; InScopeSet
</span><a href="GHC.Types.Var.Env.html#mkInScopeSet"><span class="hs-identifier hs-var">mkInScopeSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#mkVarSet"><span class="hs-identifier hs-var">mkVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163416"><span class="hs-identifier hs-var">skol_tvs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">VarEnv PredType
</span><a href="#local-6989586621681163394"><span class="hs-identifier hs-var">mini_env</span></a></span><span>
</span><span id="line-503"></span><span>                          </span><span id="local-6989586621681163387"><span class="annot"><span class="annottext">mb_info :: AssocInstInfo
</span><a href="#local-6989586621681163387"><span class="hs-identifier hs-var hs-var">mb_info</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InClsInst :: Class -&gt; [Id] -&gt; VarEnv PredType -&gt; AssocInstInfo
</span><a href="GHC.Tc.Instance.Class.html#InClsInst"><span class="hs-identifier hs-type">InClsInst</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ai_class :: Class
</span><a href="GHC.Tc.Instance.Class.html#ai_class"><span class="hs-identifier hs-var">ai_class</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163420"><span class="hs-identifier hs-var">clas</span></a></span><span>
</span><span id="line-504"></span><span>                                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ai_tyvars :: [Id]
</span><a href="GHC.Tc.Instance.Class.html#ai_tyvars"><span class="hs-identifier hs-var">ai_tyvars</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163402"><span class="hs-identifier hs-var">visible_skol_tvs</span></a></span><span>
</span><span id="line-505"></span><span>                                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ai_inst_env :: VarEnv PredType
</span><a href="GHC.Tc.Instance.Class.html#ai_inst_env"><span class="hs-identifier hs-var">ai_inst_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">VarEnv PredType
</span><a href="#local-6989586621681163394"><span class="hs-identifier hs-var">mini_env</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-506"></span><span>                    </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163382"><span class="annot"><span class="annottext">[(FamInst, Maybe DerivInfo)]
</span><a href="#local-6989586621681163382"><span class="hs-identifier hs-var">df_stuff</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(LDataFamInstDecl (GhcPass 'Renamed)
 -&gt; TcM (FamInst, Maybe DerivInfo))
-&gt; [LDataFamInstDecl (GhcPass 'Renamed)]
-&gt; TcRn [(FamInst, Maybe DerivInfo)]
forall a b. (a -&gt; TcRn b) -&gt; [a] -&gt; TcRn [b]
</span><a href="GHC.Tc.Utils.Monad.html#mapAndRecoverM"><span class="hs-identifier hs-var">mapAndRecoverM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AssocInstInfo
-&gt; TyVarEnv Name
-&gt; LDataFamInstDecl (GhcPass 'Renamed)
-&gt; TcM (FamInst, Maybe DerivInfo)
</span><a href="GHC.Tc.TyCl.Instance.html#tcDataFamInstDecl"><span class="hs-identifier hs-var">tcDataFamInstDecl</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163387"><span class="hs-identifier hs-var">mb_info</span></a></span><span> </span><span class="annot"><span class="annottext">TyVarEnv Name
</span><a href="#local-6989586621681163410"><span class="hs-identifier hs-var">tv_skol_env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LDataFamInstDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163429"><span class="hs-identifier hs-var">adts</span></a></span><span>
</span><span id="line-507"></span><span>                    </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163381"><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163381"><span class="hs-identifier hs-var">tf_insts1</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(LTyFamInstDecl (GhcPass 'Renamed) -&gt; TcM FamInst)
-&gt; [LTyFamInstDecl (GhcPass 'Renamed)] -&gt; TcRn [FamInst]
forall a b. (a -&gt; TcRn b) -&gt; [a] -&gt; TcRn [b]
</span><a href="GHC.Tc.Utils.Monad.html#mapAndRecoverM"><span class="hs-identifier hs-var">mapAndRecoverM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AssocInstInfo -&gt; LTyFamInstDecl (GhcPass 'Renamed) -&gt; TcM FamInst
</span><a href="GHC.Tc.TyCl.Instance.html#tcTyFamInstDecl"><span class="hs-identifier hs-var">tcTyFamInstDecl</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163387"><span class="hs-identifier hs-var">mb_info</span></a></span><span class="hs-special">)</span><span>   </span><span class="annot"><span class="annottext">[LTyFamInstDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163433"><span class="hs-identifier hs-var">ats</span></a></span><span>
</span><span id="line-508"></span><span>
</span><span id="line-509"></span><span>                      </span><span class="hs-comment">-- Check for missing associated types and build them</span><span>
</span><span id="line-510"></span><span>                      </span><span class="hs-comment">-- from their defaults (if available)</span><span>
</span><span id="line-511"></span><span>                    </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163380"><span class="annot"><span class="annottext">[[FamInst]]
</span><a href="#local-6989586621681163380"><span class="hs-identifier hs-var">tf_insts2</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(ClassATItem -&gt; TcRn [FamInst])
-&gt; [ClassATItem] -&gt; IOEnv (Env TcGblEnv TcLclEnv) [[FamInst]]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; TCvSubst -&gt; NameSet -&gt; ClassATItem -&gt; TcRn [FamInst]
</span><a href="GHC.Tc.TyCl.Class.html#tcATDefault"><span class="hs-identifier hs-var">tcATDefault</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163442"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681163391"><span class="hs-identifier hs-var">mini_subst</span></a></span><span> </span><span class="annot"><span class="annottext">NameSet
</span><a href="#local-6989586621681163378"><span class="hs-identifier hs-var">defined_ats</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-512"></span><span>                                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; [ClassATItem]
</span><a href="GHC.Core.Class.html#classATItems"><span class="hs-identifier hs-var">classATItems</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163420"><span class="hs-identifier hs-var">clas</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-513"></span><span>
</span><span id="line-514"></span><span>                    </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([(FamInst, Maybe DerivInfo)], [FamInst])
-&gt; TcM ([(FamInst, Maybe DerivInfo)], [FamInst])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(FamInst, Maybe DerivInfo)]
</span><a href="#local-6989586621681163382"><span class="hs-identifier hs-var">df_stuff</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163381"><span class="hs-identifier hs-var">tf_insts1</span></a></span><span> </span><span class="annot"><span class="annottext">[FamInst] -&gt; [FamInst] -&gt; [FamInst]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[[FamInst]] -&gt; [FamInst]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="annot"><span class="annottext">[[FamInst]]
</span><a href="#local-6989586621681163380"><span class="hs-identifier hs-var">tf_insts2</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-515"></span><span>
</span><span id="line-516"></span><span>
</span><span id="line-517"></span><span>        </span><span class="hs-comment">-- Finally, construct the Core representation of the instance.</span><span>
</span><span id="line-518"></span><span>        </span><span class="hs-comment">-- (This no longer includes the associated types.)</span><span>
</span><span id="line-519"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163376"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681163376"><span class="hs-identifier hs-var">dfun_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Class -&gt; [PredType] -&gt; SrcSpan -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Env.html#newDFunName"><span class="hs-identifier hs-var">newDFunName</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163420"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163419"><span class="hs-identifier hs-var">inst_tys</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsType (GhcPass 'Renamed) -&gt; SrcSpan
forall l e. GenLocated l e -&gt; l
</span><a href="GHC.Types.SrcLoc.html#getLoc"><span class="hs-identifier hs-var">getLoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed) -&gt; LHsType (GhcPass 'Renamed)
forall (p :: Pass). LHsSigType (GhcPass p) -&gt; LHsType (GhcPass p)
</span><a href="GHC.Hs.Type.html#hsSigType"><span class="hs-identifier hs-var">hsSigType</span></a></span><span> </span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681163439"><span class="hs-identifier hs-var">hs_ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-520"></span><span>                </span><span class="hs-comment">-- Dfun location is that of instance *header*</span><span>
</span><span id="line-521"></span><span>
</span><span id="line-522"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163372"><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681163372"><span class="hs-identifier hs-var">ispec</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe OverlapMode
-&gt; Name -&gt; [Id] -&gt; [PredType] -&gt; Class -&gt; [PredType] -&gt; TcM ClsInst
</span><a href="GHC.Tc.Utils.Instantiate.html#newClsInst"><span class="hs-identifier hs-var">newClsInst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Located OverlapMode -&gt; OverlapMode)
-&gt; Maybe (Located OverlapMode) -&gt; Maybe OverlapMode
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Located OverlapMode -&gt; OverlapMode
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Located OverlapMode)
</span><a href="#local-6989586621681163431"><span class="hs-identifier hs-var">overlap_mode</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681163376"><span class="hs-identifier hs-var">dfun_name</span></a></span><span>
</span><span id="line-523"></span><span>                              </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163422"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163421"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163420"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163419"><span class="hs-identifier hs-var">inst_tys</span></a></span><span>
</span><span id="line-524"></span><span>
</span><span id="line-525"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163369"><span class="annot"><span class="annottext">inst_binds :: InstBindings (GhcPass 'Renamed)
</span><a href="#local-6989586621681163369"><span class="hs-identifier hs-var hs-var">inst_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstBindings :: forall a.
[Name]
-&gt; LHsBinds a -&gt; [LSig a] -&gt; [Extension] -&gt; Bool -&gt; InstBindings a
</span><a href="GHC.Tc.Utils.Env.html#InstBindings"><span class="hs-identifier hs-type">InstBindings</span></a></span><span>
</span><span id="line-526"></span><span>                             </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ib_binds :: LHsBinds (GhcPass 'Renamed)
</span><a href="GHC.Tc.Utils.Env.html#ib_binds"><span class="hs-identifier hs-var">ib_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681163437"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-527"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ib_tyvars :: [Name]
</span><a href="GHC.Tc.Utils.Env.html#ib_tyvars"><span class="hs-identifier hs-var">ib_tyvars</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Name) -&gt; [Id] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Var.html#varName"><span class="hs-identifier hs-var hs-var">Var.varName</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163422"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="hs-comment">-- Scope over bindings</span><span>
</span><span id="line-528"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ib_pragmas :: [LSig (GhcPass 'Renamed)]
</span><a href="GHC.Tc.Utils.Env.html#ib_pragmas"><span class="hs-identifier hs-var">ib_pragmas</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163435"><span class="hs-identifier hs-var">uprags</span></a></span><span>
</span><span id="line-529"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ib_extensions :: [Extension]
</span><a href="GHC.Tc.Utils.Env.html#ib_extensions"><span class="hs-identifier hs-var">ib_extensions</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-530"></span><span>                             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ib_derived :: Bool
</span><a href="GHC.Tc.Utils.Env.html#ib_derived"><span class="hs-identifier hs-var">ib_derived</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-531"></span><span>              </span><span id="local-6989586621681163361"><span class="annot"><span class="annottext">inst_info :: InstInfo (GhcPass 'Renamed)
</span><a href="#local-6989586621681163361"><span class="hs-identifier hs-var hs-var">inst_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstInfo :: forall a. ClsInst -&gt; InstBindings a -&gt; InstInfo a
</span><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">iSpec :: ClsInst
</span><a href="GHC.Tc.Utils.Env.html#iSpec"><span class="hs-identifier hs-var">iSpec</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681163372"><span class="hs-identifier hs-var">ispec</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">iBinds :: InstBindings (GhcPass 'Renamed)
</span><a href="GHC.Tc.Utils.Env.html#iBinds"><span class="hs-identifier hs-var">iBinds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstBindings (GhcPass 'Renamed)
</span><a href="#local-6989586621681163369"><span class="hs-identifier hs-var">inst_binds</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-532"></span><span>
</span><span id="line-533"></span><span>              </span><span class="hs-special">(</span><span id="local-6989586621681163358"><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163358"><span class="hs-identifier hs-var">datafam_insts</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163357"><span class="annot"><span class="annottext">[Maybe DerivInfo]
</span><a href="#local-6989586621681163357"><span class="hs-identifier hs-var">m_deriv_infos</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(FamInst, Maybe DerivInfo)] -&gt; ([FamInst], [Maybe DerivInfo])
forall a b. [(a, b)] -&gt; ([a], [b])
</span><a href="../../base/src/GHC.List.html#unzip"><span class="hs-identifier hs-var">unzip</span></a></span><span> </span><span class="annot"><span class="annottext">[(FamInst, Maybe DerivInfo)]
</span><a href="#local-6989586621681163397"><span class="hs-identifier hs-var">datafam_stuff</span></a></span><span>
</span><span id="line-534"></span><span>              </span><span id="local-6989586621681163355"><span class="annot"><span class="annottext">deriv_infos :: [DerivInfo]
</span><a href="#local-6989586621681163355"><span class="hs-identifier hs-var hs-var">deriv_infos</span></a></span></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Maybe DerivInfo] -&gt; [DerivInfo]
forall a. [Maybe a] -&gt; [a]
</span><a href="../../base/src/Data.Maybe.html#catMaybes"><span class="hs-identifier hs-var">catMaybes</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe DerivInfo]
</span><a href="#local-6989586621681163357"><span class="hs-identifier hs-var">m_deriv_infos</span></a></span><span>
</span><span id="line-535"></span><span>              </span><span id="local-6989586621681163353"><span class="annot"><span class="annottext">all_insts :: [FamInst]
</span><a href="#local-6989586621681163353"><span class="hs-identifier hs-var hs-var">all_insts</span></a></span></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163396"><span class="hs-identifier hs-var">tyfam_insts</span></a></span><span> </span><span class="annot"><span class="annottext">[FamInst] -&gt; [FamInst] -&gt; [FamInst]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163358"><span class="hs-identifier hs-var">datafam_insts</span></a></span><span>
</span><span id="line-536"></span><span>
</span><span id="line-537"></span><span>         </span><span class="hs-comment">-- In hs-boot files there should be no bindings</span><span>
</span><span id="line-538"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163352"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681163352"><span class="hs-identifier hs-var">is_boot</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn Bool
</span><a href="GHC.Tc.Utils.Monad.html#tcIsHsBootOrSig"><span class="hs-identifier hs-var">tcIsHsBootOrSig</span></a></span><span>
</span><span id="line-539"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163350"><span class="annot"><span class="annottext">no_binds :: Bool
</span><a href="#local-6989586621681163350"><span class="hs-identifier hs-var hs-var">no_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed) -&gt; Bool
forall idL idR. LHsBindsLR idL idR -&gt; Bool
</span><a href="GHC.Hs.Binds.html#isEmptyLHsBinds"><span class="hs-identifier hs-var">isEmptyLHsBinds</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681163437"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163435"><span class="hs-identifier hs-var">uprags</span></a></span><span>
</span><span id="line-540"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#failIfTc"><span class="hs-identifier hs-var">failIfTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681163352"><span class="hs-identifier hs-var">is_boot</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681163350"><span class="hs-identifier hs-var">no_binds</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Tc.Gen.Bind.html#badBootDeclErr"><span class="hs-identifier hs-var">badBootDeclErr</span></a></span><span>
</span><span id="line-541"></span><span>
</span><span id="line-542"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
-&gt; TcRn ([InstInfo (GhcPass 'Renamed)], [FamInst], [DerivInfo])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">InstInfo (GhcPass 'Renamed)
</span><a href="#local-6989586621681163361"><span class="hs-identifier hs-var">inst_info</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[FamInst]
</span><a href="#local-6989586621681163353"><span class="hs-identifier hs-var">all_insts</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[DerivInfo]
</span><a href="#local-6989586621681163355"><span class="hs-identifier hs-var">deriv_infos</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-543"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-544"></span><span>    </span><span id="local-6989586621681163378"><span class="annot"><span class="annottext">defined_ats :: NameSet
</span><a href="#local-6989586621681163378"><span class="hs-identifier hs-var hs-var">defined_ats</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; NameSet
</span><a href="GHC.Types.Name.Set.html#mkNameSet"><span class="hs-identifier hs-var">mkNameSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LTyFamInstDecl (GhcPass 'Renamed) -&gt; Name)
-&gt; [LTyFamInstDecl (GhcPass 'Renamed)] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyFamInstDecl (GhcPass 'Renamed) -&gt; Name
forall (p :: Pass). TyFamInstDecl (GhcPass p) -&gt; IdP (GhcPass p)
</span><a href="GHC.Hs.Decls.html#tyFamInstDeclName"><span class="hs-identifier hs-var">tyFamInstDeclName</span></a></span><span> </span><span class="annot"><span class="annottext">(TyFamInstDecl (GhcPass 'Renamed) -&gt; Name)
-&gt; (LTyFamInstDecl (GhcPass 'Renamed)
    -&gt; TyFamInstDecl (GhcPass 'Renamed))
-&gt; LTyFamInstDecl (GhcPass 'Renamed)
-&gt; Name
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">LTyFamInstDecl (GhcPass 'Renamed)
-&gt; TyFamInstDecl (GhcPass 'Renamed)
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LTyFamInstDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163433"><span class="hs-identifier hs-var">ats</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-545"></span><span>                  </span><span class="annot"><span class="annottext">NameSet -&gt; NameSet -&gt; NameSet
</span><a href="GHC.Types.Name.Set.html#unionNameSet"><span class="hs-operator hs-var">`unionNameSet`</span></a></span><span>
</span><span id="line-546"></span><span>                  </span><span class="annot"><span class="annottext">[Name] -&gt; NameSet
</span><a href="GHC.Types.Name.Set.html#mkNameSet"><span class="hs-identifier hs-var">mkNameSet</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(LDataFamInstDecl (GhcPass 'Renamed) -&gt; Name)
-&gt; [LDataFamInstDecl (GhcPass 'Renamed)] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenLocated SrcSpan Name -&gt; Name
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">(GenLocated SrcSpan Name -&gt; Name)
-&gt; (LDataFamInstDecl (GhcPass 'Renamed) -&gt; GenLocated SrcSpan Name)
-&gt; LDataFamInstDecl (GhcPass 'Renamed)
-&gt; Name
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed))
-&gt; GenLocated SrcSpan Name
forall pass rhs. FamEqn pass rhs -&gt; Located (IdP pass)
</span><a href="GHC.Hs.Decls.html#feqn_tycon"><span class="hs-identifier hs-var hs-var">feqn_tycon</span></a></span><span>
</span><span id="line-547"></span><span>                                        </span><span class="annot"><span class="annottext">(FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed))
 -&gt; GenLocated SrcSpan Name)
-&gt; (LDataFamInstDecl (GhcPass 'Renamed)
    -&gt; FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed)))
-&gt; LDataFamInstDecl (GhcPass 'Renamed)
-&gt; GenLocated SrcSpan Name
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">HsImplicitBndrs
  (GhcPass 'Renamed)
  (FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed)))
-&gt; FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed))
forall pass thing. HsImplicitBndrs pass thing -&gt; thing
</span><a href="GHC.Hs.Type.html#hsib_body"><span class="hs-identifier hs-var hs-var">hsib_body</span></a></span><span>
</span><span id="line-548"></span><span>                                        </span><span class="annot"><span class="annottext">(HsImplicitBndrs
   (GhcPass 'Renamed)
   (FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed)))
 -&gt; FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed)))
-&gt; (LDataFamInstDecl (GhcPass 'Renamed)
    -&gt; HsImplicitBndrs
         (GhcPass 'Renamed)
         (FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed))))
-&gt; LDataFamInstDecl (GhcPass 'Renamed)
-&gt; FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed))
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">DataFamInstDecl (GhcPass 'Renamed)
-&gt; HsImplicitBndrs
     (GhcPass 'Renamed)
     (FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed)))
forall pass.
DataFamInstDecl pass -&gt; FamInstEqn pass (HsDataDefn pass)
</span><a href="GHC.Hs.Decls.html#dfid_eqn"><span class="hs-identifier hs-var hs-var">dfid_eqn</span></a></span><span>
</span><span id="line-549"></span><span>                                        </span><span class="annot"><span class="annottext">(DataFamInstDecl (GhcPass 'Renamed)
 -&gt; HsImplicitBndrs
      (GhcPass 'Renamed)
      (FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed))))
-&gt; (LDataFamInstDecl (GhcPass 'Renamed)
    -&gt; DataFamInstDecl (GhcPass 'Renamed))
-&gt; LDataFamInstDecl (GhcPass 'Renamed)
-&gt; HsImplicitBndrs
     (GhcPass 'Renamed)
     (FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed)))
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">LDataFamInstDecl (GhcPass 'Renamed)
-&gt; DataFamInstDecl (GhcPass 'Renamed)
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LDataFamInstDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163429"><span class="hs-identifier hs-var">adts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-550"></span><span>
</span><span id="line-551"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
               Type family instances
*                                                                      *
************************************************************************

Family instances are somewhat of a hybrid.  They are processed together with
class instance heads, but can contain data constructors and hence they share a
lot of kinding and type checking code with ordinary algebraic data types (and
GADTs).
-}</span><span>
</span><span id="line-563"></span><span>
</span><span id="line-564"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcTyFamInstDecl"><span class="hs-identifier hs-type">tcTyFamInstDecl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.Class.html#AssocInstInfo"><span class="hs-identifier hs-type">AssocInstInfo</span></a></span><span>
</span><span id="line-565"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#LTyFamInstDecl"><span class="hs-identifier hs-type">LTyFamInstDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInst"><span class="hs-identifier hs-type">FamInst</span></a></span><span>
</span><span id="line-566"></span><span>  </span><span class="hs-comment">-- &quot;type instance&quot;</span><span>
</span><span id="line-567"></span><span>  </span><span class="hs-comment">-- See Note [Associated type instances]</span><span>
</span><span id="line-568"></span><span id="tcTyFamInstDecl"><span class="annot"><span class="annottext">tcTyFamInstDecl :: AssocInstInfo -&gt; LTyFamInstDecl (GhcPass 'Renamed) -&gt; TcM FamInst
</span><a href="GHC.Tc.TyCl.Instance.html#tcTyFamInstDecl"><span class="hs-identifier hs-var hs-var">tcTyFamInstDecl</span></a></span></span><span> </span><span id="local-6989586621681163337"><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163337"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681163336"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163336"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681163335"><span class="annot"><span class="annottext">decl :: TyFamInstDecl (GhcPass 'Renamed)
</span><a href="#local-6989586621681163335"><span class="hs-identifier hs-var">decl</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#TyFamInstDecl"><span class="hs-identifier hs-type">TyFamInstDecl</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tfid_eqn :: forall pass. TyFamInstDecl pass -&gt; TyFamInstEqn pass
</span><a href="GHC.Hs.Decls.html#tfid_eqn"><span class="hs-identifier hs-var">tfid_eqn</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163332"><span class="annot"><span class="annottext">TyFamInstEqn (GhcPass 'Renamed)
</span><a href="#local-6989586621681163332"><span class="hs-identifier hs-var">eqn</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-569"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TcM FamInst -&gt; TcM FamInst
forall a. SrcSpan -&gt; TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#setSrcSpan"><span class="hs-identifier hs-var">setSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163336"><span class="hs-identifier hs-var">loc</span></a></span><span>           </span><span class="annot"><span class="annottext">(TcM FamInst -&gt; TcM FamInst) -&gt; TcM FamInst -&gt; TcM FamInst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-570"></span><span>    </span><span class="annot"><span class="annottext">TyFamInstDecl (GhcPass 'Renamed) -&gt; TcM FamInst -&gt; TcM FamInst
forall a. TyFamInstDecl (GhcPass 'Renamed) -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.TyCl.html#tcAddTyFamInstCtxt"><span class="hs-identifier hs-var">tcAddTyFamInstCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">TyFamInstDecl (GhcPass 'Renamed)
</span><a href="#local-6989586621681163335"><span class="hs-identifier hs-var">decl</span></a></span><span>  </span><span class="annot"><span class="annottext">(TcM FamInst -&gt; TcM FamInst) -&gt; TcM FamInst -&gt; TcM FamInst
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-571"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163330"><span class="annot"><span class="annottext">fam_lname :: Located (IdP (GhcPass 'Renamed))
</span><a href="#local-6989586621681163330"><span class="hs-identifier hs-var hs-var">fam_lname</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FamEqn (GhcPass 'Renamed) (LHsType (GhcPass 'Renamed))
-&gt; Located (IdP (GhcPass 'Renamed))
forall pass rhs. FamEqn pass rhs -&gt; Located (IdP pass)
</span><a href="GHC.Hs.Decls.html#feqn_tycon"><span class="hs-identifier hs-var hs-var">feqn_tycon</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyFamInstEqn (GhcPass 'Renamed)
-&gt; FamEqn (GhcPass 'Renamed) (LHsType (GhcPass 'Renamed))
forall pass thing. HsImplicitBndrs pass thing -&gt; thing
</span><a href="GHC.Hs.Type.html#hsib_body"><span class="hs-identifier hs-var hs-var">hsib_body</span></a></span><span> </span><span class="annot"><span class="annottext">TyFamInstEqn (GhcPass 'Renamed)
</span><a href="#local-6989586621681163332"><span class="hs-identifier hs-var">eqn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-572"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163329"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163329"><span class="hs-identifier hs-var">fam_tc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name -&gt; TcM TyCon
</span><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedTyCon"><span class="hs-identifier hs-var">tcLookupLocatedTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name
Located (IdP (GhcPass 'Renamed))
</span><a href="#local-6989586621681163330"><span class="hs-identifier hs-var">fam_lname</span></a></span><span>
</span><span id="line-573"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">AssocInstInfo -&gt; TyCon -&gt; TcRn ()
</span><a href="GHC.Tc.TyCl.Instance.html#tcFamInstDeclChecks"><span class="hs-identifier hs-var">tcFamInstDeclChecks</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163337"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163329"><span class="hs-identifier hs-var">fam_tc</span></a></span><span>
</span><span id="line-574"></span><span>
</span><span id="line-575"></span><span>         </span><span class="hs-comment">-- (0) Check it's an open type family</span><span>
</span><span id="line-576"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#checkTc"><span class="hs-identifier hs-var">checkTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isTypeFamilyTyCon"><span class="hs-identifier hs-var">isTypeFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163329"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span>     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
</span><a href="GHC.Tc.TyCl.html#wrongKindOfFamily"><span class="hs-identifier hs-var">wrongKindOfFamily</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163329"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-577"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#checkTc"><span class="hs-identifier hs-var">checkTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isOpenTypeFamilyTyCon"><span class="hs-identifier hs-var">isOpenTypeFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163329"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#notOpenFamily"><span class="hs-identifier hs-var">notOpenFamily</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163329"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-578"></span><span>
</span><span id="line-579"></span><span>         </span><span class="hs-comment">-- (1) do the work of verifying the synonym group</span><span>
</span><span id="line-580"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163321"><span class="annot"><span class="annottext">KnotTied CoAxBranch
</span><a href="#local-6989586621681163321"><span class="hs-identifier hs-var">co_ax_branch</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon
-&gt; AssocInstInfo
-&gt; LTyFamInstEqn (GhcPass 'Renamed)
-&gt; TcM (KnotTied CoAxBranch)
</span><a href="GHC.Tc.TyCl.html#tcTyFamInstEqn"><span class="hs-identifier hs-var">tcTyFamInstEqn</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163329"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163337"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span><span>
</span><span id="line-581"></span><span>                                        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan
-&gt; TyFamInstEqn (GhcPass 'Renamed)
-&gt; LTyFamInstEqn (GhcPass 'Renamed)
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenLocated SrcSpan Name -&gt; SrcSpan
forall l e. GenLocated l e -&gt; l
</span><a href="GHC.Types.SrcLoc.html#getLoc"><span class="hs-identifier hs-var">getLoc</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name
Located (IdP (GhcPass 'Renamed))
</span><a href="#local-6989586621681163330"><span class="hs-identifier hs-var">fam_lname</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">TyFamInstEqn (GhcPass 'Renamed)
</span><a href="#local-6989586621681163332"><span class="hs-identifier hs-var">eqn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-582"></span><span>
</span><span id="line-583"></span><span>
</span><span id="line-584"></span><span>         </span><span class="hs-comment">-- (2) check for validity</span><span>
</span><span id="line-585"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">AssocInstInfo -&gt; TyCon -&gt; KnotTied CoAxBranch -&gt; TcRn ()
</span><a href="GHC.Tc.Validity.html#checkConsistentFamInst"><span class="hs-identifier hs-var">checkConsistentFamInst</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163337"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163329"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">KnotTied CoAxBranch
</span><a href="#local-6989586621681163321"><span class="hs-identifier hs-var">co_ax_branch</span></a></span><span>
</span><span id="line-586"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; KnotTied CoAxBranch -&gt; TcRn ()
</span><a href="GHC.Tc.Validity.html#checkValidCoAxBranch"><span class="hs-identifier hs-var">checkValidCoAxBranch</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163329"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">KnotTied CoAxBranch
</span><a href="#local-6989586621681163321"><span class="hs-identifier hs-var">co_ax_branch</span></a></span><span>
</span><span id="line-587"></span><span>
</span><span id="line-588"></span><span>         </span><span class="hs-comment">-- (3) construct coercion axiom</span><span>
</span><span id="line-589"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163317"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681163317"><span class="hs-identifier hs-var">rep_tc_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name -&gt; [[PredType]] -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Env.html#newFamInstAxiomName"><span class="hs-identifier hs-var">newFamInstAxiomName</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name
Located (IdP (GhcPass 'Renamed))
</span><a href="#local-6989586621681163330"><span class="hs-identifier hs-var">fam_lname</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">KnotTied CoAxBranch -&gt; [PredType]
</span><a href="GHC.Core.Coercion.Axiom.html#coAxBranchLHS"><span class="hs-identifier hs-var">coAxBranchLHS</span></a></span><span> </span><span class="annot"><span class="annottext">KnotTied CoAxBranch
</span><a href="#local-6989586621681163321"><span class="hs-identifier hs-var">co_ax_branch</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-590"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163314"><span class="annot"><span class="annottext">axiom :: CoAxiom Unbranched
</span><a href="#local-6989586621681163314"><span class="hs-identifier hs-var hs-var">axiom</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TyCon -&gt; KnotTied CoAxBranch -&gt; CoAxiom Unbranched
</span><a href="GHC.Core.FamInstEnv.html#mkUnbranchedCoAxiom"><span class="hs-identifier hs-var">mkUnbranchedCoAxiom</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681163317"><span class="hs-identifier hs-var">rep_tc_name</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163329"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">KnotTied CoAxBranch
</span><a href="#local-6989586621681163321"><span class="hs-identifier hs-var">co_ax_branch</span></a></span><span>
</span><span id="line-591"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">FamFlavor -&gt; CoAxiom Unbranched -&gt; TcM FamInst
</span><a href="GHC.Tc.Instance.Family.html#newFamInst"><span class="hs-identifier hs-var">newFamInst</span></a></span><span> </span><span class="annot"><span class="annottext">FamFlavor
</span><a href="GHC.Core.FamInstEnv.html#SynFamilyInst"><span class="hs-identifier hs-var">SynFamilyInst</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiom Unbranched
</span><a href="#local-6989586621681163314"><span class="hs-identifier hs-var">axiom</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-592"></span><span>
</span><span id="line-593"></span><span>
</span><span id="line-594"></span><span class="hs-comment">---------------------</span><span>
</span><span id="line-595"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcFamInstDeclChecks"><span class="hs-identifier hs-type">tcFamInstDeclChecks</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.Class.html#AssocInstInfo"><span class="hs-identifier hs-type">AssocInstInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-596"></span><span class="hs-comment">-- Used for both type and data families</span><span>
</span><span id="line-597"></span><span id="tcFamInstDeclChecks"><span class="annot"><span class="annottext">tcFamInstDeclChecks :: AssocInstInfo -&gt; TyCon -&gt; TcRn ()
</span><a href="GHC.Tc.TyCl.Instance.html#tcFamInstDeclChecks"><span class="hs-identifier hs-var hs-var">tcFamInstDeclChecks</span></a></span></span><span> </span><span id="local-6989586621681163310"><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163310"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span></span><span> </span><span id="local-6989586621681163309"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163309"><span class="hs-identifier hs-var">fam_tc</span></a></span></span><span>
</span><span id="line-598"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- Type family instances require -XTypeFamilies</span><span>
</span><span id="line-599"></span><span>         </span><span class="hs-comment">-- and can't (currently) be in an hs-boot file</span><span>
</span><span id="line-600"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcFamInstDecl&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163309"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-601"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163308"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681163308"><span class="hs-identifier hs-var">type_families</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRn Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#TypeFamilies"><span class="hs-identifier hs-var">LangExt.TypeFamilies</span></a></span><span>
</span><span id="line-602"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163305"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681163305"><span class="hs-identifier hs-var">is_boot</span></a></span></span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn Bool
</span><a href="GHC.Tc.Utils.Monad.html#tcIsHsBootOrSig"><span class="hs-identifier hs-var">tcIsHsBootOrSig</span></a></span><span>   </span><span class="hs-comment">-- Are we compiling an hs-boot file?</span><span>
</span><span id="line-603"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#checkTc"><span class="hs-identifier hs-var">checkTc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681163308"><span class="hs-identifier hs-var">type_families</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#badFamInstDecl"><span class="hs-identifier hs-var">badFamInstDecl</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163309"><span class="hs-identifier hs-var">fam_tc</span></a></span><span>
</span><span id="line-604"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#checkTc"><span class="hs-identifier hs-var">checkTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681163305"><span class="hs-identifier hs-var">is_boot</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#badBootFamInstDeclErr"><span class="hs-identifier hs-var">badBootFamInstDeclErr</span></a></span><span>
</span><span id="line-605"></span><span>
</span><span id="line-606"></span><span>       </span><span class="hs-comment">-- Check that it is a family TyCon, and that</span><span>
</span><span id="line-607"></span><span>       </span><span class="hs-comment">-- oplevel type instances are not for associated types.</span><span>
</span><span id="line-608"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#checkTc"><span class="hs-identifier hs-var">checkTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isFamilyTyCon"><span class="hs-identifier hs-var">isFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163309"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#notFamily"><span class="hs-identifier hs-var">notFamily</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163309"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-609"></span><span>
</span><span id="line-610"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; TcRn () -&gt; TcRn ()
forall (f :: * -&gt; *). Applicative f =&gt; Bool -&gt; f () -&gt; f ()
</span><a href="../../base/src/GHC.Base.html#when"><span class="hs-identifier hs-var">when</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">AssocInstInfo -&gt; Bool
</span><a href="GHC.Tc.Instance.Class.html#isNotAssociated"><span class="hs-identifier hs-var">isNotAssociated</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163310"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span>   </span><span class="hs-comment">-- Not in a class decl</span><span>
</span><span id="line-611"></span><span>               </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isTyConAssoc"><span class="hs-identifier hs-var">isTyConAssoc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163309"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span>            </span><span class="hs-comment">-- but an associated type</span><span>
</span><span id="line-612"></span><span>              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#addErr"><span class="hs-identifier hs-var">addErr</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#assocInClassErr"><span class="hs-identifier hs-var">assocInClassErr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163309"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-613"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-614"></span><span>
</span><span id="line-615"></span><span class="hs-comment">{- Note [Associated type instances]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We allow this:
  class C a where
    type T x a
  instance C Int where
    type T (S y) Int = y
    type T Z     Int = Char

Note that
  a) The variable 'x' is not bound by the class decl
  b) 'x' is instantiated to a non-type-variable in the instance
  c) There are several type instance decls for T in the instance

All this is fine.  Of course, you can't give any *more* instances
for (T ty Int) elsewhere, because it's an *associated* type.


************************************************************************
*                                                                      *
               Data family instances
*                                                                      *
************************************************************************

For some reason data family instances are a lot more complicated
than type family instances
-}</span><span>
</span><span id="line-642"></span><span>
</span><span id="line-643"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcDataFamInstDecl"><span class="hs-identifier hs-type">tcDataFamInstDecl</span></a></span><span> </span><span class="hs-glyph">::</span><span>
</span><span id="line-644"></span><span>     </span><span class="annot"><a href="GHC.Tc.Instance.Class.html#AssocInstInfo"><span class="hs-identifier hs-type">AssocInstInfo</span></a></span><span>
</span><span id="line-645"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TyVarEnv"><span class="hs-identifier hs-type">TyVarEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-comment">-- If this is an associated data family instance, maps the</span><span>
</span><span id="line-646"></span><span>                   </span><span class="hs-comment">-- parent class's skolemized type variables to their</span><span>
</span><span id="line-647"></span><span>                   </span><span class="hs-comment">-- original Names. If this is a non-associated instance,</span><span>
</span><span id="line-648"></span><span>                   </span><span class="hs-comment">-- this will be empty.</span><span>
</span><span id="line-649"></span><span>                   </span><span class="hs-comment">-- See Note [Associated data family instances and di_scoped_tvs].</span><span>
</span><span id="line-650"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#LDataFamInstDecl"><span class="hs-identifier hs-type">LDataFamInstDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.FamInstEnv.html#FamInst"><span class="hs-identifier hs-type">FamInst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.html#DerivInfo"><span class="hs-identifier hs-type">DerivInfo</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-651"></span><span>  </span><span class="hs-comment">-- &quot;newtype instance&quot; and &quot;data instance&quot;</span><span>
</span><span id="line-652"></span><span id="tcDataFamInstDecl"><span class="annot"><span class="annottext">tcDataFamInstDecl :: AssocInstInfo
-&gt; TyVarEnv Name
-&gt; LDataFamInstDecl (GhcPass 'Renamed)
-&gt; TcM (FamInst, Maybe DerivInfo)
</span><a href="GHC.Tc.TyCl.Instance.html#tcDataFamInstDecl"><span class="hs-identifier hs-var hs-var">tcDataFamInstDecl</span></a></span></span><span> </span><span id="local-6989586621681163296"><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163296"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span></span><span> </span><span id="local-6989586621681163295"><span class="annot"><span class="annottext">TyVarEnv Name
</span><a href="#local-6989586621681163295"><span class="hs-identifier hs-var">tv_skol_env</span></a></span></span><span>
</span><span id="line-653"></span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681163294"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163294"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681163293"><span class="annot"><span class="annottext">decl :: DataFamInstDecl (GhcPass 'Renamed)
</span><a href="#local-6989586621681163293"><span class="hs-identifier hs-var">decl</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#DataFamInstDecl"><span class="hs-identifier hs-type">DataFamInstDecl</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dfid_eqn :: forall pass.
DataFamInstDecl pass -&gt; FamInstEqn pass (HsDataDefn pass)
</span><a href="GHC.Hs.Decls.html#dfid_eqn"><span class="hs-identifier hs-var">dfid_eqn</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Hs.Type.html#HsIB"><span class="hs-identifier hs-type">HsIB</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">hsib_ext :: forall pass thing. HsImplicitBndrs pass thing -&gt; XHsIB pass thing
</span><a href="GHC.Hs.Type.html#hsib_ext"><span class="hs-identifier hs-var">hsib_ext</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163289"><span class="annot"><span class="annottext">XHsIB
  (GhcPass 'Renamed)
  (FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed)))
</span><a href="#local-6989586621681163289"><span class="hs-identifier hs-var">imp_vars</span></a></span></span><span>
</span><span id="line-654"></span><span>                                                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">hsib_body :: forall pass thing. HsImplicitBndrs pass thing -&gt; thing
</span><a href="GHC.Hs.Type.html#hsib_body"><span class="hs-identifier hs-var">hsib_body</span></a></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-655"></span><span>      </span><span class="annot"><a href="GHC.Hs.Decls.html#FamEqn"><span class="hs-identifier hs-type">FamEqn</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">feqn_bndrs :: forall pass rhs. FamEqn pass rhs -&gt; Maybe [LHsTyVarBndr () pass]
</span><a href="GHC.Hs.Decls.html#feqn_bndrs"><span class="hs-identifier hs-var">feqn_bndrs</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163286"><span class="annot"><span class="annottext">Maybe [LHsTyVarBndr () (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163286"><span class="hs-identifier hs-var">mb_bndrs</span></a></span></span><span>
</span><span id="line-656"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">feqn_pats :: forall pass rhs. FamEqn pass rhs -&gt; HsTyPats pass
</span><a href="GHC.Hs.Decls.html#feqn_pats"><span class="hs-identifier hs-var">feqn_pats</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163284"><span class="annot"><span class="annottext">HsTyPats (GhcPass 'Renamed)
</span><a href="#local-6989586621681163284"><span class="hs-identifier hs-var">hs_pats</span></a></span></span><span>
</span><span id="line-657"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">feqn_tycon :: forall pass rhs. FamEqn pass rhs -&gt; Located (IdP pass)
</span><a href="GHC.Hs.Decls.html#feqn_tycon"><span class="hs-identifier hs-var">feqn_tycon</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163283"><span class="annot"><span class="annottext">lfam_name :: Located (IdP (GhcPass 'Renamed))
</span><a href="#local-6989586621681163283"><span class="hs-identifier hs-var">lfam_name</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681163282"><span class="annot"><span class="annottext">IdP (GhcPass 'Renamed)
</span><a href="#local-6989586621681163282"><span class="hs-identifier hs-var">fam_name</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-658"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">feqn_fixity :: forall pass rhs. FamEqn pass rhs -&gt; LexicalFixity
</span><a href="GHC.Hs.Decls.html#feqn_fixity"><span class="hs-identifier hs-var">feqn_fixity</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163280"><span class="annot"><span class="annottext">LexicalFixity
</span><a href="#local-6989586621681163280"><span class="hs-identifier hs-var">fixity</span></a></span></span><span>
</span><span id="line-659"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">feqn_rhs :: forall pass rhs. FamEqn pass rhs -&gt; rhs
</span><a href="GHC.Hs.Decls.html#feqn_rhs"><span class="hs-identifier hs-var">feqn_rhs</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#HsDataDefn"><span class="hs-identifier hs-type">HsDataDefn</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dd_ND :: forall pass. HsDataDefn pass -&gt; NewOrData
</span><a href="GHC.Hs.Decls.html#dd_ND"><span class="hs-identifier hs-var">dd_ND</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163276"><span class="annot"><span class="annottext">NewOrData
</span><a href="#local-6989586621681163276"><span class="hs-identifier hs-var">new_or_data</span></a></span></span><span>
</span><span id="line-660"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dd_cType :: forall pass. HsDataDefn pass -&gt; Maybe (Located CType)
</span><a href="GHC.Hs.Decls.html#dd_cType"><span class="hs-identifier hs-var">dd_cType</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163274"><span class="annot"><span class="annottext">Maybe (Located CType)
</span><a href="#local-6989586621681163274"><span class="hs-identifier hs-var">cType</span></a></span></span><span>
</span><span id="line-661"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dd_ctxt :: forall pass. HsDataDefn pass -&gt; LHsContext pass
</span><a href="GHC.Hs.Decls.html#dd_ctxt"><span class="hs-identifier hs-var">dd_ctxt</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163272"><span class="annot"><span class="annottext">LHsContext (GhcPass 'Renamed)
</span><a href="#local-6989586621681163272"><span class="hs-identifier hs-var">hs_ctxt</span></a></span></span><span>
</span><span id="line-662"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dd_cons :: forall pass. HsDataDefn pass -&gt; [LConDecl pass]
</span><a href="GHC.Hs.Decls.html#dd_cons"><span class="hs-identifier hs-var">dd_cons</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163270"><span class="annot"><span class="annottext">[LConDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163270"><span class="hs-identifier hs-var">hs_cons</span></a></span></span><span>
</span><span id="line-663"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dd_kindSig :: forall pass. HsDataDefn pass -&gt; Maybe (LHsKind pass)
</span><a href="GHC.Hs.Decls.html#dd_kindSig"><span class="hs-identifier hs-var">dd_kindSig</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163268"><span class="annot"><span class="annottext">Maybe (LHsType (GhcPass 'Renamed))
</span><a href="#local-6989586621681163268"><span class="hs-identifier hs-var">m_ksig</span></a></span></span><span>
</span><span id="line-664"></span><span>                                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dd_derivs :: forall pass. HsDataDefn pass -&gt; HsDeriving pass
</span><a href="GHC.Hs.Decls.html#dd_derivs"><span class="hs-identifier hs-var">dd_derivs</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163266"><span class="annot"><span class="annottext">HsDeriving (GhcPass 'Renamed)
</span><a href="#local-6989586621681163266"><span class="hs-identifier hs-var">derivs</span></a></span></span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span class="hs-special">}</span><span class="hs-special">}</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-665"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan
-&gt; TcM (FamInst, Maybe DerivInfo) -&gt; TcM (FamInst, Maybe DerivInfo)
forall a. SrcSpan -&gt; TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#setSrcSpan"><span class="hs-identifier hs-var">setSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163294"><span class="hs-identifier hs-var">loc</span></a></span><span>             </span><span class="annot"><span class="annottext">(TcM (FamInst, Maybe DerivInfo) -&gt; TcM (FamInst, Maybe DerivInfo))
-&gt; TcM (FamInst, Maybe DerivInfo) -&gt; TcM (FamInst, Maybe DerivInfo)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-666"></span><span>    </span><span class="annot"><span class="annottext">DataFamInstDecl (GhcPass 'Renamed)
-&gt; TcM (FamInst, Maybe DerivInfo) -&gt; TcM (FamInst, Maybe DerivInfo)
forall a. DataFamInstDecl (GhcPass 'Renamed) -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.TyCl.html#tcAddDataFamInstCtxt"><span class="hs-identifier hs-var">tcAddDataFamInstCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">DataFamInstDecl (GhcPass 'Renamed)
</span><a href="#local-6989586621681163293"><span class="hs-identifier hs-var">decl</span></a></span><span>  </span><span class="annot"><span class="annottext">(TcM (FamInst, Maybe DerivInfo) -&gt; TcM (FamInst, Maybe DerivInfo))
-&gt; TcM (FamInst, Maybe DerivInfo) -&gt; TcM (FamInst, Maybe DerivInfo)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-667"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681163264"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name -&gt; TcM TyCon
</span><a href="GHC.Tc.Utils.Env.html#tcLookupLocatedTyCon"><span class="hs-identifier hs-var">tcLookupLocatedTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name
Located (IdP (GhcPass 'Renamed))
</span><a href="#local-6989586621681163283"><span class="hs-identifier hs-var">lfam_name</span></a></span><span>
</span><span id="line-668"></span><span>
</span><span id="line-669"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">AssocInstInfo -&gt; TyCon -&gt; TcRn ()
</span><a href="GHC.Tc.TyCl.Instance.html#tcFamInstDeclChecks"><span class="hs-identifier hs-var">tcFamInstDeclChecks</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163296"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span>
</span><span id="line-670"></span><span>
</span><span id="line-671"></span><span>       </span><span class="hs-comment">-- Check that the family declaration is for the right kind</span><span>
</span><span id="line-672"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#checkTc"><span class="hs-identifier hs-var">checkTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isDataFamilyTyCon"><span class="hs-identifier hs-var">isDataFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
</span><a href="GHC.Tc.TyCl.html#wrongKindOfFamily"><span class="hs-identifier hs-var">wrongKindOfFamily</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-673"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163262"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681163262"><span class="hs-identifier hs-var">gadt_syntax</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name
-&gt; NewOrData
-&gt; LHsContext (GhcPass 'Renamed)
-&gt; [LConDecl (GhcPass 'Renamed)]
-&gt; TcRn Bool
</span><a href="GHC.Tc.TyCl.html#dataDeclChecks"><span class="hs-identifier hs-var">dataDeclChecks</span></a></span><span> </span><span class="annot"><span class="annottext">Name
IdP (GhcPass 'Renamed)
</span><a href="#local-6989586621681163282"><span class="hs-identifier hs-var">fam_name</span></a></span><span> </span><span class="annot"><span class="annottext">NewOrData
</span><a href="#local-6989586621681163276"><span class="hs-identifier hs-var">new_or_data</span></a></span><span> </span><span class="annot"><span class="annottext">LHsContext (GhcPass 'Renamed)
</span><a href="#local-6989586621681163272"><span class="hs-identifier hs-var">hs_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">[LConDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163270"><span class="hs-identifier hs-var">hs_cons</span></a></span><span>
</span><span id="line-674"></span><span>          </span><span class="hs-comment">-- Do /not/ check that the number of patterns = tyConArity fam_tc</span><span>
</span><span id="line-675"></span><span>          </span><span class="hs-comment">-- See [Arity of data families] in GHC.Core.FamInstEnv</span><span>
</span><span id="line-676"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163260"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163260"><span class="hs-identifier hs-var">qtvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163259"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163259"><span class="hs-identifier hs-var">pats</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163258"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163258"><span class="hs-identifier hs-var">res_kind</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163257"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163257"><span class="hs-identifier hs-var">stupid_theta</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-677"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
-&gt; TyCon
-&gt; [Name]
-&gt; Maybe [LHsTyVarBndr () (GhcPass 'Renamed)]
-&gt; LexicalFixity
-&gt; LHsContext (GhcPass 'Renamed)
-&gt; HsTyPats (GhcPass 'Renamed)
-&gt; Maybe (LHsType (GhcPass 'Renamed))
-&gt; [LConDecl (GhcPass 'Renamed)]
-&gt; NewOrData
-&gt; TcM ([Id], [PredType], PredType, [PredType])
</span><a href="GHC.Tc.TyCl.Instance.html#tcDataFamInstHeader"><span class="hs-identifier hs-var">tcDataFamInstHeader</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163296"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
XHsIB
  (GhcPass 'Renamed)
  (FamEqn (GhcPass 'Renamed) (HsDataDefn (GhcPass 'Renamed)))
</span><a href="#local-6989586621681163289"><span class="hs-identifier hs-var">imp_vars</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe [LHsTyVarBndr () (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163286"><span class="hs-identifier hs-var">mb_bndrs</span></a></span><span>
</span><span id="line-678"></span><span>                                    </span><span class="annot"><span class="annottext">LexicalFixity
</span><a href="#local-6989586621681163280"><span class="hs-identifier hs-var">fixity</span></a></span><span> </span><span class="annot"><span class="annottext">LHsContext (GhcPass 'Renamed)
</span><a href="#local-6989586621681163272"><span class="hs-identifier hs-var">hs_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">HsTyPats (GhcPass 'Renamed)
</span><a href="#local-6989586621681163284"><span class="hs-identifier hs-var">hs_pats</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (LHsType (GhcPass 'Renamed))
</span><a href="#local-6989586621681163268"><span class="hs-identifier hs-var">m_ksig</span></a></span><span> </span><span class="annot"><span class="annottext">[LConDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163270"><span class="hs-identifier hs-var">hs_cons</span></a></span><span>
</span><span id="line-679"></span><span>                                    </span><span class="annot"><span class="annottext">NewOrData
</span><a href="#local-6989586621681163276"><span class="hs-identifier hs-var">new_or_data</span></a></span><span>
</span><span id="line-680"></span><span>
</span><span id="line-681"></span><span>       </span><span class="hs-comment">-- Eta-reduce the axiom if possible</span><span>
</span><span id="line-682"></span><span>       </span><span class="hs-comment">-- Quite tricky: see Note [Implementing eta reduction for data families]</span><span>
</span><span id="line-683"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163255"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163255"><span class="hs-identifier hs-var">eta_pats</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163254"><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163254"><span class="hs-identifier hs-var">eta_tcbs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [PredType] -&gt; ([PredType], [TyConBinder])
</span><a href="#local-6989586621681163253"><span class="hs-identifier hs-var">eta_reduce</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163259"><span class="hs-identifier hs-var">pats</span></a></span><span>
</span><span id="line-684"></span><span>             </span><span id="local-6989586621681163252"><span class="annot"><span class="annottext">eta_tvs :: [Id]
</span><a href="#local-6989586621681163252"><span class="hs-identifier hs-var hs-var">eta_tvs</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyConBinder -&gt; Id) -&gt; [TyConBinder] -&gt; [Id]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">TyConBinder -&gt; Id
forall tv argf. VarBndr tv argf -&gt; tv
</span><a href="GHC.Types.Var.html#binderVar"><span class="hs-identifier hs-var">binderVar</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163254"><span class="hs-identifier hs-var">eta_tcbs</span></a></span><span>
</span><span id="line-685"></span><span>             </span><span id="local-6989586621681163250"><span class="annot"><span class="annottext">post_eta_qtvs :: [Id]
</span><a href="#local-6989586621681163250"><span class="hs-identifier hs-var hs-var">post_eta_qtvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Bool) -&gt; [Id] -&gt; [Id]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#filterOut"><span class="hs-identifier hs-var">filterOut</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163252"><span class="hs-identifier hs-var">eta_tvs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163260"><span class="hs-identifier hs-var">qtvs</span></a></span><span>
</span><span id="line-686"></span><span>
</span><span id="line-687"></span><span>             </span><span id="local-6989586621681163247"><span class="annot"><span class="annottext">full_tcbs :: [TyConBinder]
</span><a href="#local-6989586621681163247"><span class="hs-identifier hs-var hs-var">full_tcbs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; VarSet -&gt; [TyConBinder]
</span><a href="GHC.Core.Type.html#mkTyConBindersPreferAnon"><span class="hs-identifier hs-var">mkTyConBindersPreferAnon</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163250"><span class="hs-identifier hs-var">post_eta_qtvs</span></a></span><span>
</span><span id="line-688"></span><span>                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; PredType -&gt; PredType
</span><a href="GHC.Core.Type.html#mkSpecForAllTys"><span class="hs-identifier hs-var">mkSpecForAllTys</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163252"><span class="hs-identifier hs-var">eta_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163258"><span class="hs-identifier hs-var">res_kind</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-689"></span><span>                         </span><span class="annot"><span class="annottext">[TyConBinder] -&gt; [TyConBinder] -&gt; [TyConBinder]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163254"><span class="hs-identifier hs-var">eta_tcbs</span></a></span><span>
</span><span id="line-690"></span><span>                 </span><span class="hs-comment">-- Put the eta-removed tyvars at the end</span><span>
</span><span id="line-691"></span><span>                 </span><span class="hs-comment">-- Remember, qtvs is in arbitrary order, except kind vars are</span><span>
</span><span id="line-692"></span><span>                 </span><span class="hs-comment">-- first, so there is no reason to suppose that the eta_tvs</span><span>
</span><span id="line-693"></span><span>                 </span><span class="hs-comment">-- (obtained from the pats) are at the end (#11148)</span><span>
</span><span id="line-694"></span><span>
</span><span id="line-695"></span><span>       </span><span class="hs-comment">-- Eta-expand the representation tycon until it has result</span><span>
</span><span id="line-696"></span><span>       </span><span class="hs-comment">-- kind `TYPE r`, for some `r`. If UnliftedNewtypes is not enabled, we</span><span>
</span><span id="line-697"></span><span>       </span><span class="hs-comment">-- go one step further and ensure that it has kind `TYPE 'LiftedRep`.</span><span>
</span><span id="line-698"></span><span>       </span><span class="hs-comment">--</span><span>
</span><span id="line-699"></span><span>       </span><span class="hs-comment">-- See also Note [Arity of data families] in GHC.Core.FamInstEnv</span><span>
</span><span id="line-700"></span><span>       </span><span class="hs-comment">-- NB: we can do this after eta-reducing the axiom, because if</span><span>
</span><span id="line-701"></span><span>       </span><span class="hs-comment">--     we did it before the &quot;extra&quot; tvs from etaExpandAlgTyCon</span><span>
</span><span id="line-702"></span><span>       </span><span class="hs-comment">--     would always be eta-reduced</span><span>
</span><span id="line-703"></span><span>       </span><span class="hs-comment">--</span><span>
</span><span id="line-704"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163243"><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163243"><span class="hs-identifier hs-var">extra_tcbs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163242"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163242"><span class="hs-identifier hs-var">final_res_kind</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[TyConBinder] -&gt; PredType -&gt; TcM ([TyConBinder], PredType)
</span><a href="GHC.Tc.Gen.HsType.html#etaExpandAlgTyCon"><span class="hs-identifier hs-var">etaExpandAlgTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163247"><span class="hs-identifier hs-var">full_tcbs</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163258"><span class="hs-identifier hs-var">res_kind</span></a></span><span>
</span><span id="line-705"></span><span>
</span><span id="line-706"></span><span>       </span><span class="hs-comment">-- Check the result kind; it may come from a user-written signature.</span><span>
</span><span id="line-707"></span><span>       </span><span class="hs-comment">-- See Note [Datatype return kinds] in GHC.Tc.TyCl point 4(a)</span><span>
</span><span id="line-708"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163240"><span class="annot"><span class="annottext">extra_pats :: [PredType]
</span><a href="#local-6989586621681163240"><span class="hs-identifier hs-var hs-var">extra_pats</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(TyConBinder -&gt; PredType) -&gt; [TyConBinder] -&gt; [PredType]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTy"><span class="hs-identifier hs-var">mkTyVarTy</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; PredType) -&gt; (TyConBinder -&gt; Id) -&gt; TyConBinder -&gt; PredType
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">TyConBinder -&gt; Id
forall tv argf. VarBndr tv argf -&gt; tv
</span><a href="GHC.Types.Var.html#binderVar"><span class="hs-identifier hs-var">binderVar</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163243"><span class="hs-identifier hs-var">extra_tcbs</span></a></span><span>
</span><span id="line-709"></span><span>             </span><span id="local-6989586621681163238"><span class="annot"><span class="annottext">all_pats :: [PredType]
</span><a href="#local-6989586621681163238"><span class="hs-identifier hs-var hs-var">all_pats</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163259"><span class="hs-identifier hs-var">pats</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; [PredType] -&gt; [PredType]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#chkAppend"><span class="hs-operator hs-var">`chkAppend`</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163240"><span class="hs-identifier hs-var">extra_pats</span></a></span><span>
</span><span id="line-710"></span><span>             </span><span id="local-6989586621681163236"><span class="annot"><span class="annottext">orig_res_ty :: PredType
</span><a href="#local-6989586621681163236"><span class="hs-identifier hs-var hs-var">orig_res_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [PredType] -&gt; PredType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163238"><span class="hs-identifier hs-var">all_pats</span></a></span><span>
</span><span id="line-711"></span><span>             </span><span id="local-6989586621681163234"><span class="annot"><span class="annottext">ty_binders :: [TyConBinder]
</span><a href="#local-6989586621681163234"><span class="hs-identifier hs-var hs-var">ty_binders</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163247"><span class="hs-identifier hs-var">full_tcbs</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder] -&gt; [TyConBinder] -&gt; [TyConBinder]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Utils.Misc.html#chkAppend"><span class="hs-operator hs-var">`chkAppend`</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163243"><span class="hs-identifier hs-var">extra_tcbs</span></a></span><span>
</span><span id="line-712"></span><span>
</span><span id="line-713"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcDataFamInstDecl&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-714"></span><span>         </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Fam tycon:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span>
</span><span id="line-715"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Pats:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163259"><span class="hs-identifier hs-var">pats</span></a></span><span>
</span><span id="line-716"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;visiblities:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBndrVis] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [PredType] -&gt; [TyConBndrVis]
</span><a href="GHC.Tc.Gen.HsType.html#tcbVisibilities"><span class="hs-identifier hs-var">tcbVisibilities</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163259"><span class="hs-identifier hs-var">pats</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-717"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;all_pats:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163238"><span class="hs-identifier hs-var">all_pats</span></a></span><span>
</span><span id="line-718"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ty_binders&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163234"><span class="hs-identifier hs-var">ty_binders</span></a></span><span>
</span><span id="line-719"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;fam_tc_binders:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [TyConBinder]
</span><a href="GHC.Core.TyCon.html#tyConBinders"><span class="hs-identifier hs-var hs-var">tyConBinders</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-720"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;res_kind:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163258"><span class="hs-identifier hs-var">res_kind</span></a></span><span>
</span><span id="line-721"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;final_res_kind:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163242"><span class="hs-identifier hs-var">final_res_kind</span></a></span><span>
</span><span id="line-722"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;eta_pats&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163255"><span class="hs-identifier hs-var">eta_pats</span></a></span><span>
</span><span id="line-723"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;eta_tcbs&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163254"><span class="hs-identifier hs-var">eta_tcbs</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-724"></span><span>
</span><span id="line-725"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163228"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163228"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163227"><span class="annot"><span class="annottext">CoAxiom Unbranched
</span><a href="#local-6989586621681163227"><span class="hs-identifier hs-var">axiom</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((TyCon, CoAxiom Unbranched)
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TyCon, CoAxiom Unbranched))
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TyCon, CoAxiom Unbranched)
forall a env. (a -&gt; IOEnv env a) -&gt; IOEnv env a
</span><a href="GHC.Data.IOEnv.html#fixM"><span class="hs-identifier hs-var">fixM</span></a></span><span> </span><span class="annot"><span class="annottext">(((TyCon, CoAxiom Unbranched)
  -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TyCon, CoAxiom Unbranched))
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TyCon, CoAxiom Unbranched))
-&gt; ((TyCon, CoAxiom Unbranched)
    -&gt; IOEnv (Env TcGblEnv TcLclEnv) (TyCon, CoAxiom Unbranched))
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TyCon, CoAxiom Unbranched)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span> </span><span class="hs-glyph">~</span><span class="hs-special">(</span><span id="local-6989586621681163225"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163225"><span class="hs-identifier hs-var">rec_rep_tc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoAxiom Unbranched
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-726"></span><span>           </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681163224"><span class="annot"><span class="annottext">[DataCon]
</span><a href="#local-6989586621681163224"><span class="hs-identifier hs-var">data_cons</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; TcM [DataCon] -&gt; TcM [DataCon]
forall r. [Id] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendTyVarEnv"><span class="hs-identifier hs-var">tcExtendTyVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163260"><span class="hs-identifier hs-var">qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM [DataCon] -&gt; TcM [DataCon]) -&gt; TcM [DataCon] -&gt; TcM [DataCon]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-727"></span><span>                  </span><span class="hs-comment">-- For H98 decls, the tyvars scope</span><span>
</span><span id="line-728"></span><span>                  </span><span class="hs-comment">-- over the data constructors</span><span>
</span><span id="line-729"></span><span>                  </span><span class="annot"><span class="annottext">TyCon
-&gt; NewOrData
-&gt; [TyConBinder]
-&gt; PredType
-&gt; PredType
-&gt; [LConDecl (GhcPass 'Renamed)]
-&gt; TcM [DataCon]
</span><a href="GHC.Tc.TyCl.html#tcConDecls"><span class="hs-identifier hs-var">tcConDecls</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163225"><span class="hs-identifier hs-var">rec_rep_tc</span></a></span><span> </span><span class="annot"><span class="annottext">NewOrData
</span><a href="#local-6989586621681163276"><span class="hs-identifier hs-var">new_or_data</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163234"><span class="hs-identifier hs-var">ty_binders</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163242"><span class="hs-identifier hs-var">final_res_kind</span></a></span><span>
</span><span id="line-730"></span><span>                             </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163236"><span class="hs-identifier hs-var">orig_res_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[LConDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163270"><span class="hs-identifier hs-var">hs_cons</span></a></span><span>
</span><span id="line-731"></span><span>
</span><span id="line-732"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163221"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681163221"><span class="hs-identifier hs-var">rep_tc_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name -&gt; [PredType] -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Env.html#newFamInstTyConName"><span class="hs-identifier hs-var">newFamInstTyConName</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name
Located (IdP (GhcPass 'Renamed))
</span><a href="#local-6989586621681163283"><span class="hs-identifier hs-var">lfam_name</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163259"><span class="hs-identifier hs-var">pats</span></a></span><span>
</span><span id="line-733"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163219"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681163219"><span class="hs-identifier hs-var">axiom_name</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name -&gt; [[PredType]] -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Env.html#newFamInstAxiomName"><span class="hs-identifier hs-var">newFamInstAxiomName</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name
Located (IdP (GhcPass 'Renamed))
</span><a href="#local-6989586621681163283"><span class="hs-identifier hs-var">lfam_name</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163259"><span class="hs-identifier hs-var">pats</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-734"></span><span>              </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163218"><span class="annot"><span class="annottext">AlgTyConRhs
</span><a href="#local-6989586621681163218"><span class="hs-identifier hs-var">tc_rhs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">NewOrData
</span><a href="#local-6989586621681163276"><span class="hs-identifier hs-var">new_or_data</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-735"></span><span>                     </span><span class="annot"><span class="annottext">NewOrData
</span><a href="GHC.Hs.Decls.html#DataType"><span class="hs-identifier hs-var">DataType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">AlgTyConRhs -&gt; IOEnv (Env TcGblEnv TcLclEnv) AlgTyConRhs
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[DataCon] -&gt; AlgTyConRhs
</span><a href="GHC.Core.TyCon.html#mkDataTyConRhs"><span class="hs-identifier hs-var">mkDataTyConRhs</span></a></span><span> </span><span class="annot"><span class="annottext">[DataCon]
</span><a href="#local-6989586621681163224"><span class="hs-identifier hs-var">data_cons</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-736"></span><span>                     </span><span class="annot"><span class="annottext">NewOrData
</span><a href="GHC.Hs.Decls.html#NewType"><span class="hs-identifier hs-var">NewType</span></a></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">ASSERT</span><span class="hs-special">(</span><span> </span><span class="hs-identifier">not</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">null</span><span> </span><span class="hs-identifier">data_cons</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-737"></span><span>                                 </span><span class="annot"><span class="annottext">Name
-&gt; TyCon -&gt; DataCon -&gt; IOEnv (Env TcGblEnv TcLclEnv) AlgTyConRhs
forall m n. Name -&gt; TyCon -&gt; DataCon -&gt; TcRnIf m n AlgTyConRhs
</span><a href="GHC.Tc.TyCl.Build.html#mkNewTyConRhs"><span class="hs-identifier hs-var">mkNewTyConRhs</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681163221"><span class="hs-identifier hs-var">rep_tc_name</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163225"><span class="hs-identifier hs-var">rec_rep_tc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[DataCon] -&gt; DataCon
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#head"><span class="hs-identifier hs-var">head</span></a></span><span> </span><span class="annot"><span class="annottext">[DataCon]
</span><a href="#local-6989586621681163224"><span class="hs-identifier hs-var">data_cons</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-738"></span><span>
</span><span id="line-739"></span><span>              </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163210"><span class="annot"><span class="annottext">ax_rhs :: PredType
</span><a href="#local-6989586621681163210"><span class="hs-identifier hs-var hs-var">ax_rhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [PredType] -&gt; PredType
</span><a href="GHC.Core.TyCo.Rep.html#mkTyConApp"><span class="hs-identifier hs-var">mkTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163209"><span class="hs-identifier hs-var">rep_tc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [PredType]
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTys"><span class="hs-identifier hs-var">mkTyVarTys</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163250"><span class="hs-identifier hs-var">post_eta_qtvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-740"></span><span>                    </span><span id="local-6989586621681163207"><span class="annot"><span class="annottext">axiom :: CoAxiom Unbranched
</span><a href="#local-6989586621681163207"><span class="hs-identifier hs-var hs-var">axiom</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Role
-&gt; Name
-&gt; [Id]
-&gt; [Id]
-&gt; [Id]
-&gt; TyCon
-&gt; [PredType]
-&gt; PredType
-&gt; CoAxiom Unbranched
</span><a href="GHC.Core.FamInstEnv.html#mkSingleCoAxiom"><span class="hs-identifier hs-var">mkSingleCoAxiom</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Representational"><span class="hs-identifier hs-var">Representational</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681163219"><span class="hs-identifier hs-var">axiom_name</span></a></span><span>
</span><span id="line-741"></span><span>                                 </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163250"><span class="hs-identifier hs-var">post_eta_qtvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163252"><span class="hs-identifier hs-var">eta_tvs</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163255"><span class="hs-identifier hs-var">eta_pats</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163210"><span class="hs-identifier hs-var">ax_rhs</span></a></span><span>
</span><span id="line-742"></span><span>                    </span><span id="local-6989586621681163204"><span class="annot"><span class="annottext">parent :: AlgTyConFlav
</span><a href="#local-6989586621681163204"><span class="hs-identifier hs-var hs-var">parent</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoAxiom Unbranched -&gt; TyCon -&gt; [PredType] -&gt; AlgTyConFlav
</span><a href="GHC.Core.TyCon.html#DataFamInstTyCon"><span class="hs-identifier hs-var">DataFamInstTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiom Unbranched
</span><a href="#local-6989586621681163207"><span class="hs-identifier hs-var">axiom</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163238"><span class="hs-identifier hs-var">all_pats</span></a></span><span>
</span><span id="line-743"></span><span>
</span><span id="line-744"></span><span>                      </span><span class="hs-comment">-- NB: Use the full ty_binders from the pats. See bullet toward</span><span>
</span><span id="line-745"></span><span>                      </span><span class="hs-comment">-- the end of Note [Data type families] in GHC.Core.TyCon</span><span>
</span><span id="line-746"></span><span>                    </span><span id="local-6989586621681163209"><span class="annot"><span class="annottext">rep_tc :: TyCon
</span><a href="#local-6989586621681163209"><span class="hs-identifier hs-var hs-var">rep_tc</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name
-&gt; [TyConBinder]
-&gt; PredType
-&gt; [Role]
-&gt; Maybe CType
-&gt; [PredType]
-&gt; AlgTyConRhs
-&gt; AlgTyConFlav
-&gt; Bool
-&gt; TyCon
</span><a href="GHC.Core.TyCon.html#mkAlgTyCon"><span class="hs-identifier hs-var">mkAlgTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681163221"><span class="hs-identifier hs-var">rep_tc_name</span></a></span><span>
</span><span id="line-747"></span><span>                                          </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163234"><span class="hs-identifier hs-var">ty_binders</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163242"><span class="hs-identifier hs-var">final_res_kind</span></a></span><span>
</span><span id="line-748"></span><span>                                          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(TyConBinder -&gt; Role) -&gt; [TyConBinder] -&gt; [Role]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Role -&gt; TyConBinder -&gt; Role
forall a b. a -&gt; b -&gt; a
</span><a href="../../base/src/GHC.Base.html#const"><span class="hs-identifier hs-var">const</span></a></span><span> </span><span class="annot"><span class="annottext">Role
</span><a href="GHC.Core.Coercion.Axiom.html#Nominal"><span class="hs-identifier hs-var">Nominal</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TyConBinder]
</span><a href="#local-6989586621681163234"><span class="hs-identifier hs-var">ty_binders</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-749"></span><span>                                          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Located CType -&gt; CType) -&gt; Maybe (Located CType) -&gt; Maybe CType
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">Located CType -&gt; CType
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Located CType)
</span><a href="#local-6989586621681163274"><span class="hs-identifier hs-var">cType</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163257"><span class="hs-identifier hs-var">stupid_theta</span></a></span><span>
</span><span id="line-750"></span><span>                                          </span><span class="annot"><span class="annottext">AlgTyConRhs
</span><a href="#local-6989586621681163218"><span class="hs-identifier hs-var">tc_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">AlgTyConFlav
</span><a href="#local-6989586621681163204"><span class="hs-identifier hs-var">parent</span></a></span><span>
</span><span id="line-751"></span><span>                                          </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681163262"><span class="hs-identifier hs-var">gadt_syntax</span></a></span><span>
</span><span id="line-752"></span><span>                 </span><span class="hs-comment">-- We always assume that indexed types are recursive.  Why?</span><span>
</span><span id="line-753"></span><span>                 </span><span class="hs-comment">-- (1) Due to their open nature, we can never be sure that a</span><span>
</span><span id="line-754"></span><span>                 </span><span class="hs-comment">-- further instance might not introduce a new recursive</span><span>
</span><span id="line-755"></span><span>                 </span><span class="hs-comment">-- dependency.  (2) They are always valid loop breakers as</span><span>
</span><span id="line-756"></span><span>                 </span><span class="hs-comment">-- they involve a coercion.</span><span>
</span><span id="line-757"></span><span>              </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TyCon, CoAxiom Unbranched)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (TyCon, CoAxiom Unbranched)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163209"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">CoAxiom Unbranched
</span><a href="#local-6989586621681163207"><span class="hs-identifier hs-var">axiom</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-758"></span><span>
</span><span id="line-759"></span><span>       </span><span class="hs-comment">-- Remember to check validity; no recursion to worry about here</span><span>
</span><span id="line-760"></span><span>       </span><span class="hs-comment">-- Check that left-hand sides are ok (mono-types, no type families,</span><span>
</span><span id="line-761"></span><span>       </span><span class="hs-comment">-- consistent instantiations, etc)</span><span>
</span><span id="line-762"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163199"><span class="annot"><span class="annottext">ax_branch :: KnotTied CoAxBranch
</span><a href="#local-6989586621681163199"><span class="hs-identifier hs-var hs-var">ax_branch</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CoAxiom Unbranched -&gt; KnotTied CoAxBranch
</span><a href="GHC.Core.Coercion.Axiom.html#coAxiomSingleBranch"><span class="hs-identifier hs-var">coAxiomSingleBranch</span></a></span><span> </span><span class="annot"><span class="annottext">CoAxiom Unbranched
</span><a href="#local-6989586621681163227"><span class="hs-identifier hs-var">axiom</span></a></span><span>
</span><span id="line-763"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">AssocInstInfo -&gt; TyCon -&gt; KnotTied CoAxBranch -&gt; TcRn ()
</span><a href="GHC.Tc.Validity.html#checkConsistentFamInst"><span class="hs-identifier hs-var">checkConsistentFamInst</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163296"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">KnotTied CoAxBranch
</span><a href="#local-6989586621681163199"><span class="hs-identifier hs-var">ax_branch</span></a></span><span>
</span><span id="line-764"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; KnotTied CoAxBranch -&gt; TcRn ()
</span><a href="GHC.Tc.Validity.html#checkValidCoAxBranch"><span class="hs-identifier hs-var">checkValidCoAxBranch</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163264"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">KnotTied CoAxBranch
</span><a href="#local-6989586621681163199"><span class="hs-identifier hs-var">ax_branch</span></a></span><span>
</span><span id="line-765"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TcRn ()
</span><a href="GHC.Tc.TyCl.html#checkValidTyCon"><span class="hs-identifier hs-var">checkValidTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163228"><span class="hs-identifier hs-var">rep_tc</span></a></span><span>
</span><span id="line-766"></span><span>
</span><span id="line-767"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163196"><span class="annot"><span class="annottext">scoped_tvs :: [(Name, Id)]
</span><a href="#local-6989586621681163196"><span class="hs-identifier hs-var hs-var">scoped_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; (Name, Id)) -&gt; [Id] -&gt; [(Name, Id)]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; (Name, Id)
</span><a href="#local-6989586621681163195"><span class="hs-identifier hs-var">mk_deriv_info_scoped_tv_pr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [Id]
</span><a href="GHC.Core.TyCon.html#tyConTyVars"><span class="hs-identifier hs-var hs-var">tyConTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163228"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-768"></span><span>             </span><span id="local-6989586621681163193"><span class="annot"><span class="annottext">m_deriv_info :: Maybe DerivInfo
</span><a href="#local-6989586621681163193"><span class="hs-identifier hs-var hs-var">m_deriv_info</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HsDeriving (GhcPass 'Renamed)
</span><a href="#local-6989586621681163266"><span class="hs-identifier hs-var">derivs</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-769"></span><span>               </span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe DerivInfo
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-770"></span><span>               </span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681163192"><span class="annot"><span class="annottext">[LHsDerivingClause (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163192"><span class="hs-identifier hs-var">preds</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-771"></span><span>                 </span><span class="annot"><span class="annottext">DerivInfo -&gt; Maybe DerivInfo
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">(DerivInfo -&gt; Maybe DerivInfo) -&gt; DerivInfo -&gt; Maybe DerivInfo
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DerivInfo :: TyCon
-&gt; [(Name, Id)]
-&gt; [LHsDerivingClause (GhcPass 'Renamed)]
-&gt; SDoc
-&gt; DerivInfo
</span><a href="GHC.Tc.Deriv.html#DerivInfo"><span class="hs-identifier hs-type">DerivInfo</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">di_rep_tc :: TyCon
</span><a href="GHC.Tc.Deriv.html#di_rep_tc"><span class="hs-identifier hs-var">di_rep_tc</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163228"><span class="hs-identifier hs-var">rep_tc</span></a></span><span>
</span><span id="line-772"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">di_scoped_tvs :: [(Name, Id)]
</span><a href="GHC.Tc.Deriv.html#di_scoped_tvs"><span class="hs-identifier hs-var">di_scoped_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Name, Id)]
</span><a href="#local-6989586621681163196"><span class="hs-identifier hs-var">scoped_tvs</span></a></span><span>
</span><span id="line-773"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">di_clauses :: [LHsDerivingClause (GhcPass 'Renamed)]
</span><a href="GHC.Tc.Deriv.html#di_clauses"><span class="hs-identifier hs-var">di_clauses</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LHsDerivingClause (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163192"><span class="hs-identifier hs-var">preds</span></a></span><span>
</span><span id="line-774"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">di_ctxt :: SDoc
</span><a href="GHC.Tc.Deriv.html#di_ctxt"><span class="hs-identifier hs-var">di_ctxt</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataFamInstDecl (GhcPass 'Renamed) -&gt; SDoc
</span><a href="GHC.Tc.TyCl.html#tcMkDataFamInstCtxt"><span class="hs-identifier hs-var">tcMkDataFamInstCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">DataFamInstDecl (GhcPass 'Renamed)
</span><a href="#local-6989586621681163293"><span class="hs-identifier hs-var">decl</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-775"></span><span>
</span><span id="line-776"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163185"><span class="annot"><span class="annottext">FamInst
</span><a href="#local-6989586621681163185"><span class="hs-identifier hs-var">fam_inst</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">FamFlavor -&gt; CoAxiom Unbranched -&gt; TcM FamInst
</span><a href="GHC.Tc.Instance.Family.html#newFamInst"><span class="hs-identifier hs-var">newFamInst</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; FamFlavor
</span><a href="GHC.Core.FamInstEnv.html#DataFamilyInst"><span class="hs-identifier hs-var">DataFamilyInst</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163228"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CoAxiom Unbranched
</span><a href="#local-6989586621681163227"><span class="hs-identifier hs-var">axiom</span></a></span><span>
</span><span id="line-777"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(FamInst, Maybe DerivInfo) -&gt; TcM (FamInst, Maybe DerivInfo)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FamInst
</span><a href="#local-6989586621681163185"><span class="hs-identifier hs-var">fam_inst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe DerivInfo
</span><a href="#local-6989586621681163193"><span class="hs-identifier hs-var">m_deriv_info</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-778"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-779"></span><span>    </span><span class="annot"><a href="#local-6989586621681163253"><span class="hs-identifier hs-type">eta_reduce</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyConBinder"><span class="hs-identifier hs-type">TyConBinder</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-780"></span><span>    </span><span class="hs-comment">-- See Note [Eta reduction for data families] in GHC.Core.Coercion.Axiom</span><span>
</span><span id="line-781"></span><span>    </span><span class="hs-comment">-- Splits the incoming patterns into two: the [TyVar]</span><span>
</span><span id="line-782"></span><span>    </span><span class="hs-comment">-- are the patterns that can be eta-reduced away.</span><span>
</span><span id="line-783"></span><span>    </span><span class="hs-comment">-- e.g.     T [a] Int a d c   ==&gt;  (T [a] Int a, [d,c])</span><span>
</span><span id="line-784"></span><span>    </span><span class="hs-comment">--</span><span>
</span><span id="line-785"></span><span>    </span><span class="hs-comment">-- NB: quadratic algorithm, but types are small here</span><span>
</span><span id="line-786"></span><span>    </span><span id="local-6989586621681163253"><span class="annot"><span class="annottext">eta_reduce :: TyCon -&gt; [PredType] -&gt; ([PredType], [TyConBinder])
</span><a href="#local-6989586621681163253"><span class="hs-identifier hs-var hs-var">eta_reduce</span></a></span></span><span> </span><span id="local-6989586621681163182"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163182"><span class="hs-identifier hs-var">fam_tc</span></a></span></span><span> </span><span id="local-6989586621681163181"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163181"><span class="hs-identifier hs-var">pats</span></a></span></span><span>
</span><span id="line-787"></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(PredType, VarSet, TyConBndrVis)]
-&gt; [TyConBinder] -&gt; ([PredType], [TyConBinder])
forall {c}.
[(PredType, VarSet, c)]
-&gt; [VarBndr Id c] -&gt; ([PredType], [VarBndr Id c])
</span><a href="#local-6989586621681163180"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(PredType, VarSet, TyConBndrVis)]
-&gt; [(PredType, VarSet, TyConBndrVis)]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[PredType]
-&gt; [VarSet] -&gt; [TyConBndrVis] -&gt; [(PredType, VarSet, TyConBndrVis)]
forall a b c. [a] -&gt; [b] -&gt; [c] -&gt; [(a, b, c)]
</span><a href="../../base/src/GHC.List.html#zip3"><span class="hs-identifier hs-var">zip3</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163181"><span class="hs-identifier hs-var">pats</span></a></span><span> </span><span class="annot"><span class="annottext">[VarSet]
</span><a href="#local-6989586621681163177"><span class="hs-identifier hs-var">fvs_s</span></a></span><span> </span><span class="annot"><span class="annottext">[TyConBndrVis]
</span><a href="#local-6989586621681163176"><span class="hs-identifier hs-var">vis_s</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-788"></span><span>        </span><span class="hs-keyword">where</span><span>
</span><span id="line-789"></span><span>          </span><span class="annot"><a href="#local-6989586621681163176"><span class="hs-identifier hs-type">vis_s</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCon.html#TyConBndrVis"><span class="hs-identifier hs-type">TyConBndrVis</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-790"></span><span>          </span><span id="local-6989586621681163176"><span class="annot"><span class="annottext">vis_s :: [TyConBndrVis]
</span><a href="#local-6989586621681163176"><span class="hs-identifier hs-var hs-var">vis_s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [PredType] -&gt; [TyConBndrVis]
</span><a href="GHC.Tc.Gen.HsType.html#tcbVisibilities"><span class="hs-identifier hs-var">tcbVisibilities</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163182"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163181"><span class="hs-identifier hs-var">pats</span></a></span><span>
</span><span id="line-791"></span><span>
</span><span id="line-792"></span><span>          </span><span class="annot"><a href="#local-6989586621681163177"><span class="hs-identifier hs-type">fvs_s</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.Set.html#TyCoVarSet"><span class="hs-identifier hs-type">TyCoVarSet</span></a></span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- 1-1 correspondence with pats</span><span>
</span><span id="line-793"></span><span>                                 </span><span class="hs-comment">-- Each elt is the free vars of all /earlier/ pats</span><span>
</span><span id="line-794"></span><span>          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163177"><span class="annot"><span class="annottext">[VarSet]
</span><a href="#local-6989586621681163177"><span class="hs-identifier hs-var">fvs_s</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(VarSet -&gt; PredType -&gt; (VarSet, VarSet))
-&gt; VarSet -&gt; [PredType] -&gt; (VarSet, [VarSet])
forall (t :: * -&gt; *) s a b.
Traversable t =&gt;
(s -&gt; a -&gt; (s, b)) -&gt; s -&gt; t a -&gt; (s, t b)
</span><a href="../../base/src/Data.Traversable.html#mapAccumL"><span class="hs-identifier hs-var">mapAccumL</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; PredType -&gt; (VarSet, VarSet)
</span><a href="#local-6989586621681163174"><span class="hs-identifier hs-var">add_fvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="GHC.Types.Var.Set.html#emptyVarSet"><span class="hs-identifier hs-var">emptyVarSet</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163181"><span class="hs-identifier hs-var">pats</span></a></span><span>
</span><span id="line-795"></span><span>          </span><span id="local-6989586621681163174"><span class="annot"><span class="annottext">add_fvs :: VarSet -&gt; PredType -&gt; (VarSet, VarSet)
</span><a href="#local-6989586621681163174"><span class="hs-identifier hs-var hs-var">add_fvs</span></a></span></span><span> </span><span id="local-6989586621681163172"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681163172"><span class="hs-identifier hs-var">fvs</span></a></span></span><span> </span><span id="local-6989586621681163171"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163171"><span class="hs-identifier hs-var">pat</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681163172"><span class="hs-identifier hs-var">fvs</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet -&gt; VarSet -&gt; VarSet
</span><a href="GHC.Types.Var.Set.html#unionVarSet"><span class="hs-operator hs-var">`unionVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; VarSet
</span><a href="GHC.Core.TyCo.FVs.html#tyCoVarsOfType"><span class="hs-identifier hs-var">tyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163171"><span class="hs-identifier hs-var">pat</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681163172"><span class="hs-identifier hs-var">fvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-796"></span><span>
</span><span id="line-797"></span><span>    </span><span id="local-6989586621681163180"><span class="annot"><span class="annottext">go :: [(PredType, VarSet, c)]
-&gt; [VarBndr Id c] -&gt; ([PredType], [VarBndr Id c])
</span><a href="#local-6989586621681163180"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621681163169"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163169"><span class="hs-identifier hs-var">pat</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163168"><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681163168"><span class="hs-identifier hs-var">fvs_to_the_left</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163167"><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621681163167"><span class="hs-identifier hs-var">tcb_vis</span></a></span></span><span class="hs-special">)</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621681163166"><span class="annot"><span class="annottext">[(PredType, VarSet, c)]
</span><a href="#local-6989586621681163166"><span class="hs-identifier hs-var">pats</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681163165"><span class="annot"><span class="annottext">[VarBndr Id c]
</span><a href="#local-6989586621681163165"><span class="hs-identifier hs-var">etad_tvs</span></a></span></span><span>
</span><span id="line-798"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681163164"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163164"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; Maybe Id
</span><a href="GHC.Core.Type.html#getTyVar_maybe"><span class="hs-identifier hs-var">getTyVar_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163169"><span class="hs-identifier hs-var">pat</span></a></span><span>
</span><span id="line-799"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163164"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">VarSet
</span><a href="#local-6989586621681163168"><span class="hs-identifier hs-var">fvs_to_the_left</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-800"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(PredType, VarSet, c)]
-&gt; [VarBndr Id c] -&gt; ([PredType], [VarBndr Id c])
</span><a href="#local-6989586621681163180"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">[(PredType, VarSet, c)]
</span><a href="#local-6989586621681163166"><span class="hs-identifier hs-var">pats</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; c -&gt; VarBndr Id c
forall var argf. var -&gt; argf -&gt; VarBndr var argf
</span><a href="GHC.Types.Var.html#Bndr"><span class="hs-identifier hs-var">Bndr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163164"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">c
</span><a href="#local-6989586621681163167"><span class="hs-identifier hs-var">tcb_vis</span></a></span><span> </span><span class="annot"><span class="annottext">VarBndr Id c -&gt; [VarBndr Id c] -&gt; [VarBndr Id c]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[VarBndr Id c]
</span><a href="#local-6989586621681163165"><span class="hs-identifier hs-var">etad_tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-801"></span><span>    </span><span class="annot"><a href="#local-6989586621681163180"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span id="local-6989586621681163160"><span class="annot"><span class="annottext">[(PredType, VarSet, c)]
</span><a href="#local-6989586621681163160"><span class="hs-identifier hs-var">pats</span></a></span></span><span> </span><span id="local-6989586621681163159"><span class="annot"><span class="annottext">[VarBndr Id c]
</span><a href="#local-6989586621681163159"><span class="hs-identifier hs-var">etad_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[PredType] -&gt; [PredType]
forall a. [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#reverse"><span class="hs-identifier hs-var">reverse</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((PredType, VarSet, c) -&gt; PredType)
-&gt; [(PredType, VarSet, c)] -&gt; [PredType]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">(PredType, VarSet, c) -&gt; PredType
forall a b c. (a, b, c) -&gt; a
</span><a href="GHC.Utils.Misc.html#fstOf3"><span class="hs-identifier hs-var">fstOf3</span></a></span><span> </span><span class="annot"><span class="annottext">[(PredType, VarSet, c)]
</span><a href="#local-6989586621681163160"><span class="hs-identifier hs-var">pats</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[VarBndr Id c]
</span><a href="#local-6989586621681163159"><span class="hs-identifier hs-var">etad_tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-802"></span><span>
</span><span id="line-803"></span><span>    </span><span class="hs-comment">-- Create a Name-TyVar mapping to bring into scope when typechecking any</span><span>
</span><span id="line-804"></span><span>    </span><span class="hs-comment">-- deriving clauses this data family instance may have.</span><span>
</span><span id="line-805"></span><span>    </span><span class="hs-comment">-- See Note [Associated data family instances and di_scoped_tvs].</span><span>
</span><span id="line-806"></span><span>    </span><span class="annot"><a href="#local-6989586621681163195"><span class="hs-identifier hs-type">mk_deriv_info_scoped_tv_pr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-807"></span><span>    </span><span id="local-6989586621681163195"><span class="annot"><span class="annottext">mk_deriv_info_scoped_tv_pr :: Id -&gt; (Name, Id)
</span><a href="#local-6989586621681163195"><span class="hs-identifier hs-var hs-var">mk_deriv_info_scoped_tv_pr</span></a></span></span><span> </span><span id="local-6989586621681163156"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163156"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-808"></span><span>      </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163155"><span class="annot"><span class="annottext">n :: Name
</span><a href="#local-6989586621681163155"><span class="hs-identifier hs-var hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVarEnv Name -&gt; Name -&gt; Id -&gt; Name
forall a. VarEnv a -&gt; a -&gt; Id -&gt; a
</span><a href="GHC.Types.Var.Env.html#lookupWithDefaultVarEnv"><span class="hs-identifier hs-var">lookupWithDefaultVarEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVarEnv Name
</span><a href="#local-6989586621681163295"><span class="hs-identifier hs-var">tv_skol_env</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Var.html#tyVarName"><span class="hs-identifier hs-var">tyVarName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163156"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163156"><span class="hs-identifier hs-var">tv</span></a></span><span>
</span><span id="line-809"></span><span>      </span><span class="hs-keyword">in</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681163155"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163156"><span class="hs-identifier hs-var">tv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-810"></span><span>
</span><span id="line-811"></span><span class="hs-comment">{-
Note [Associated data family instances and di_scoped_tvs]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some care is required to implement `deriving` correctly for associated data
family instances. Consider this example from #18055:

  class C a where
    data D a

  class X a b

  instance C (Maybe a) where
    data D (Maybe a) deriving (X a)

When typechecking the `X a` in `deriving (X a)`, we must ensure that the `a`
from the instance header is brought into scope. This is the role of
di_scoped_tvs, which maps from the original, renamed `a` to the skolemized,
typechecked `a`. When typechecking the `deriving` clause, this mapping will be
consulted when looking up the `a` in `X a`.

A na&#239;ve attempt at creating the di_scoped_tvs is to simply reuse the
tyConTyVars of the representation TyCon for `data D (Maybe a)`. This is only
half correct, however. We do want the typechecked `a`'s Name in the /range/
of the mapping, but we do not want it in the /domain/ of the mapping.
To ensure that the original `a`'s Name ends up in the domain, we consult a
TyVarEnv (passed as an argument to tcDataFamInstDecl) that maps from the
typechecked `a`'s Name to the original `a`'s Name. In the even that
tcDataFamInstDecl is processing a non-associated data family instance, this
TyVarEnv will simply be empty, and there is nothing to worry about.
-}</span><span>
</span><span id="line-841"></span><span>
</span><span id="line-842"></span><span class="hs-comment">-----------------------</span><span>
</span><span id="line-843"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcDataFamInstHeader"><span class="hs-identifier hs-type">tcDataFamInstHeader</span></a></span><span>
</span><span id="line-844"></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Instance.Class.html#AssocInstInfo"><span class="hs-identifier hs-type">AssocInstInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Type.html#LHsTyVarBndr"><span class="hs-identifier hs-type">LHsTyVarBndr</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-845"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#LexicalFixity"><span class="hs-identifier hs-type">LexicalFixity</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Type.html#LHsContext"><span class="hs-identifier hs-type">LHsContext</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span>
</span><span id="line-846"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#HsTyPats"><span class="hs-identifier hs-type">HsTyPats</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Type.html#LHsKind"><span class="hs-identifier hs-type">LHsKind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LConDecl"><span class="hs-identifier hs-type">LConDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-847"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#NewOrData"><span class="hs-identifier hs-type">NewOrData</span></a></span><span>
</span><span id="line-848"></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Kind"><span class="hs-identifier hs-type">Kind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-849"></span><span class="hs-comment">-- The &quot;header&quot; of a data family instance is the part other than</span><span>
</span><span id="line-850"></span><span class="hs-comment">-- the data constructors themselves</span><span>
</span><span id="line-851"></span><span class="hs-comment">--    e.g.  data instance D [a] :: * -&gt; * where ...</span><span>
</span><span id="line-852"></span><span class="hs-comment">-- Here the &quot;header&quot; is the bit before the &quot;where&quot;</span><span>
</span><span id="line-853"></span><span id="tcDataFamInstHeader"><span class="annot"><span class="annottext">tcDataFamInstHeader :: AssocInstInfo
-&gt; TyCon
-&gt; [Name]
-&gt; Maybe [LHsTyVarBndr () (GhcPass 'Renamed)]
-&gt; LexicalFixity
-&gt; LHsContext (GhcPass 'Renamed)
-&gt; HsTyPats (GhcPass 'Renamed)
-&gt; Maybe (LHsType (GhcPass 'Renamed))
-&gt; [LConDecl (GhcPass 'Renamed)]
-&gt; NewOrData
-&gt; TcM ([Id], [PredType], PredType, [PredType])
</span><a href="GHC.Tc.TyCl.Instance.html#tcDataFamInstHeader"><span class="hs-identifier hs-var hs-var">tcDataFamInstHeader</span></a></span></span><span> </span><span id="local-6989586621681163151"><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163151"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span></span><span> </span><span id="local-6989586621681163150"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163150"><span class="hs-identifier hs-var">fam_tc</span></a></span></span><span> </span><span id="local-6989586621681163149"><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681163149"><span class="hs-identifier hs-var">imp_vars</span></a></span></span><span> </span><span id="local-6989586621681163148"><span class="annot"><span class="annottext">Maybe [LHsTyVarBndr () (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163148"><span class="hs-identifier hs-var">mb_bndrs</span></a></span></span><span> </span><span id="local-6989586621681163147"><span class="annot"><span class="annottext">LexicalFixity
</span><a href="#local-6989586621681163147"><span class="hs-identifier hs-var">fixity</span></a></span></span><span>
</span><span id="line-854"></span><span>                    </span><span id="local-6989586621681163146"><span class="annot"><span class="annottext">LHsContext (GhcPass 'Renamed)
</span><a href="#local-6989586621681163146"><span class="hs-identifier hs-var">hs_ctxt</span></a></span></span><span> </span><span id="local-6989586621681163145"><span class="annot"><span class="annottext">HsTyPats (GhcPass 'Renamed)
</span><a href="#local-6989586621681163145"><span class="hs-identifier hs-var">hs_pats</span></a></span></span><span> </span><span id="local-6989586621681163144"><span class="annot"><span class="annottext">Maybe (LHsType (GhcPass 'Renamed))
</span><a href="#local-6989586621681163144"><span class="hs-identifier hs-var">m_ksig</span></a></span></span><span> </span><span id="local-6989586621681163143"><span class="annot"><span class="annottext">[LConDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163143"><span class="hs-identifier hs-var">hs_cons</span></a></span></span><span> </span><span id="local-6989586621681163142"><span class="annot"><span class="annottext">NewOrData
</span><a href="#local-6989586621681163142"><span class="hs-identifier hs-var">new_or_data</span></a></span></span><span>
</span><span id="line-855"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcDataFamInstHeader {&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163150"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">HsTyPats (GhcPass 'Renamed) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">HsTyPats (GhcPass 'Renamed)
</span><a href="#local-6989586621681163145"><span class="hs-identifier hs-var">hs_pats</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-856"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163141"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163141"><span class="hs-identifier hs-var">imp_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163140"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163140"><span class="hs-identifier hs-var">exp_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163139"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163139"><span class="hs-identifier hs-var">stupid_theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163138"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163138"><span class="hs-identifier hs-var">lhs_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163137"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163137"><span class="hs-identifier hs-var">master_res_kind</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163136"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163136"><span class="hs-identifier hs-var">instance_res_kind</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-857"></span><span>            </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
-&gt; TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
forall a. TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#pushTcLevelM_"><span class="hs-identifier hs-var">pushTcLevelM_</span></a></span><span>                                </span><span class="annot"><span class="annottext">(TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
 -&gt; TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType))))
-&gt; TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
-&gt; TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-858"></span><span>               </span><span class="annot"><span class="annottext">TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
-&gt; TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
forall a. TcM a -&gt; TcM a
</span><a href="GHC.Tc.Solver.html#solveEqualities"><span class="hs-identifier hs-var">solveEqualities</span></a></span><span>                              </span><span class="annot"><span class="annottext">(TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
 -&gt; TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType))))
-&gt; TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
-&gt; TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-859"></span><span>               </span><span class="annot"><span class="annottext">[Name]
-&gt; TcM ([Id], ([PredType], PredType, PredType, PredType))
-&gt; TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
forall a. [Name] -&gt; TcM a -&gt; TcM ([Id], a)
</span><a href="GHC.Tc.Gen.HsType.html#bindImplicitTKBndrs_Q_Skol"><span class="hs-identifier hs-var">bindImplicitTKBndrs_Q_Skol</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681163149"><span class="hs-identifier hs-var">imp_vars</span></a></span><span>          </span><span class="annot"><span class="annottext">(TcM ([Id], ([PredType], PredType, PredType, PredType))
 -&gt; TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType))))
-&gt; TcM ([Id], ([PredType], PredType, PredType, PredType))
-&gt; TcM ([Id], ([Id], ([PredType], PredType, PredType, PredType)))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-860"></span><span>               </span><span class="annot"><span class="annottext">ContextKind
-&gt; [LHsTyVarBndr () (GhcPass 'Renamed)]
-&gt; TcM ([PredType], PredType, PredType, PredType)
-&gt; TcM ([Id], ([PredType], PredType, PredType, PredType))
forall a.
ContextKind
-&gt; [LHsTyVarBndr () (GhcPass 'Renamed)] -&gt; TcM a -&gt; TcM ([Id], a)
</span><a href="GHC.Tc.Gen.HsType.html#bindExplicitTKBndrs_Q_Skol"><span class="hs-identifier hs-var">bindExplicitTKBndrs_Q_Skol</span></a></span><span> </span><span class="annot"><span class="annottext">ContextKind
</span><a href="GHC.Tc.Gen.HsType.html#AnyKind"><span class="hs-identifier hs-var">AnyKind</span></a></span><span> </span><span class="annot"><span class="annottext">[LHsTyVarBndr () (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163130"><span class="hs-identifier hs-var">exp_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM ([PredType], PredType, PredType, PredType)
 -&gt; TcM ([Id], ([PredType], PredType, PredType, PredType)))
-&gt; TcM ([PredType], PredType, PredType, PredType)
-&gt; TcM ([Id], ([PredType], PredType, PredType, PredType))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-861"></span><span>               </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681163129"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163129"><span class="hs-identifier hs-var">stupid_theta</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">LHsContext (GhcPass 'Renamed) -&gt; TcM [PredType]
</span><a href="GHC.Tc.Gen.HsType.html#tcHsContext"><span class="hs-identifier hs-var">tcHsContext</span></a></span><span> </span><span class="annot"><span class="annottext">LHsContext (GhcPass 'Renamed)
</span><a href="#local-6989586621681163146"><span class="hs-identifier hs-var">hs_ctxt</span></a></span><span>
</span><span id="line-862"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163127"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163127"><span class="hs-identifier hs-var">lhs_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163126"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163126"><span class="hs-identifier hs-var">lhs_kind</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; HsTyPats (GhcPass 'Renamed) -&gt; TcM (PredType, PredType)
</span><a href="GHC.Tc.Gen.HsType.html#tcFamTyPats"><span class="hs-identifier hs-var">tcFamTyPats</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163150"><span class="hs-identifier hs-var">fam_tc</span></a></span><span> </span><span class="annot"><span class="annottext">HsTyPats (GhcPass 'Renamed)
</span><a href="#local-6989586621681163145"><span class="hs-identifier hs-var">hs_pats</span></a></span><span>
</span><span id="line-863"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163124"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163124"><span class="hs-identifier hs-var">lhs_applied_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163123"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163123"><span class="hs-identifier hs-var">lhs_applied_kind</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-864"></span><span>                      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; PredType -&gt; TcM (PredType, PredType)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstInvisibleTyBinders"><span class="hs-identifier hs-var">tcInstInvisibleTyBinders</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163127"><span class="hs-identifier hs-var">lhs_ty</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163126"><span class="hs-identifier hs-var">lhs_kind</span></a></span><span>
</span><span id="line-865"></span><span>                      </span><span class="hs-comment">-- See Note [Data family/instance return kinds]</span><span>
</span><span id="line-866"></span><span>                      </span><span class="hs-comment">-- in GHC.Tc.TyCl point (DF3)</span><span>
</span><span id="line-867"></span><span>
</span><span id="line-868"></span><span>                  </span><span class="hs-comment">-- Ensure that the instance is consistent</span><span>
</span><span id="line-869"></span><span>                  </span><span class="hs-comment">-- with its parent class</span><span>
</span><span id="line-870"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">AssocInstInfo -&gt; PredType -&gt; TcRn ()
</span><a href="GHC.Tc.TyCl.html#addConsistencyConstraints"><span class="hs-identifier hs-var">addConsistencyConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">AssocInstInfo
</span><a href="#local-6989586621681163151"><span class="hs-identifier hs-var">mb_clsinfo</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163127"><span class="hs-identifier hs-var">lhs_ty</span></a></span><span>
</span><span id="line-871"></span><span>
</span><span id="line-872"></span><span>                  </span><span class="hs-comment">-- Add constraints from the result signature</span><span>
</span><span id="line-873"></span><span>                  </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163120"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163120"><span class="hs-identifier hs-var">res_kind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (LHsType (GhcPass 'Renamed)) -&gt; TcM PredType
</span><a href="#local-6989586621681163119"><span class="hs-identifier hs-var">tc_kind_sig</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (LHsType (GhcPass 'Renamed))
</span><a href="#local-6989586621681163144"><span class="hs-identifier hs-var">m_ksig</span></a></span><span>
</span><span id="line-874"></span><span>
</span><span id="line-875"></span><span>                  </span><span class="hs-comment">-- Add constraints from the data constructors</span><span>
</span><span id="line-876"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">NewOrData -&gt; PredType -&gt; [LConDecl (GhcPass 'Renamed)] -&gt; TcRn ()
</span><a href="GHC.Tc.TyCl.html#kcConDecls"><span class="hs-identifier hs-var">kcConDecls</span></a></span><span> </span><span class="annot"><span class="annottext">NewOrData
</span><a href="#local-6989586621681163142"><span class="hs-identifier hs-var">new_or_data</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163120"><span class="hs-identifier hs-var">res_kind</span></a></span><span> </span><span class="annot"><span class="annottext">[LConDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163143"><span class="hs-identifier hs-var">hs_cons</span></a></span><span>
</span><span id="line-877"></span><span>
</span><span id="line-878"></span><span>                  </span><span class="hs-comment">-- Check that the result kind of the TyCon applied to its args</span><span>
</span><span id="line-879"></span><span>                  </span><span class="hs-comment">-- is compatible with the explicit signature (or Type, if there</span><span>
</span><span id="line-880"></span><span>                  </span><span class="hs-comment">-- is none)</span><span>
</span><span id="line-881"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163117"><span class="annot"><span class="annottext">hs_lhs :: LHsType (GhcPass 'Renamed)
</span><a href="#local-6989586621681163117"><span class="hs-identifier hs-var hs-var">hs_lhs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LexicalFixity
-&gt; IdP (GhcPass 'Renamed)
-&gt; HsTyPats (GhcPass 'Renamed)
-&gt; LHsType (GhcPass 'Renamed)
forall (p :: Pass).
LexicalFixity
-&gt; IdP (GhcPass p)
-&gt; [LHsTypeArg (GhcPass p)]
-&gt; LHsType (GhcPass p)
</span><a href="GHC.Hs.Utils.html#nlHsTyConApp"><span class="hs-identifier hs-var">nlHsTyConApp</span></a></span><span> </span><span class="annot"><span class="annottext">LexicalFixity
</span><a href="#local-6989586621681163147"><span class="hs-identifier hs-var">fixity</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; Name
forall a. NamedThing a =&gt; a -&gt; Name
</span><a href="GHC.Types.Name.html#getName"><span class="hs-identifier hs-var">getName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163150"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">HsTyPats (GhcPass 'Renamed)
</span><a href="#local-6989586621681163145"><span class="hs-identifier hs-var">hs_pats</span></a></span><span>
</span><span id="line-882"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">CoercionN
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Maybe (HsType (GhcPass 'Renamed))
-&gt; PredType -&gt; PredType -&gt; TcM CoercionN
</span><a href="GHC.Tc.Utils.Unify.html#unifyKind"><span class="hs-identifier hs-var">unifyKind</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsType (GhcPass 'Renamed) -&gt; Maybe (HsType (GhcPass 'Renamed))
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsType (GhcPass 'Renamed) -&gt; HsType (GhcPass 'Renamed)
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">LHsType (GhcPass 'Renamed)
</span><a href="#local-6989586621681163117"><span class="hs-identifier hs-var">hs_lhs</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163123"><span class="hs-identifier hs-var">lhs_applied_kind</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163120"><span class="hs-identifier hs-var">res_kind</span></a></span><span>
</span><span id="line-883"></span><span>
</span><span id="line-884"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcDataFamInstHeader&quot;</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; SDoc -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-885"></span><span>                    </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163150"><span class="hs-identifier hs-var">fam_tc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (LHsType (GhcPass 'Renamed)) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (LHsType (GhcPass 'Renamed))
</span><a href="#local-6989586621681163144"><span class="hs-identifier hs-var">m_ksig</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163123"><span class="hs-identifier hs-var">lhs_applied_kind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163120"><span class="hs-identifier hs-var">res_kind</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-886"></span><span>                  </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([PredType], PredType, PredType, PredType)
-&gt; TcM ([PredType], PredType, PredType, PredType)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163129"><span class="hs-identifier hs-var">stupid_theta</span></a></span><span>
</span><span id="line-887"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163124"><span class="hs-identifier hs-var">lhs_applied_ty</span></a></span><span>
</span><span id="line-888"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163123"><span class="hs-identifier hs-var">lhs_applied_kind</span></a></span><span>
</span><span id="line-889"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163120"><span class="hs-identifier hs-var">res_kind</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-890"></span><span>
</span><span id="line-891"></span><span>       </span><span class="hs-comment">-- See GHC.Tc.TyCl Note [Generalising in tcFamTyPatsGuts]</span><span>
</span><span id="line-892"></span><span>       </span><span class="hs-comment">-- This code (and the stuff immediately above) is very similar</span><span>
</span><span id="line-893"></span><span>       </span><span class="hs-comment">-- to that in tcTyFamInstEqnGuts.  Maybe we should abstract the</span><span>
</span><span id="line-894"></span><span>       </span><span class="hs-comment">-- common code; but for the moment I concluded that it's</span><span>
</span><span id="line-895"></span><span>       </span><span class="hs-comment">-- clearer to duplicate it.  Still, if you fix a bug here,</span><span>
</span><span id="line-896"></span><span>       </span><span class="hs-comment">-- check there too!</span><span>
</span><span id="line-897"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163113"><span class="annot"><span class="annottext">scoped_tvs :: [Id]
</span><a href="#local-6989586621681163113"><span class="hs-identifier hs-var hs-var">scoped_tvs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163141"><span class="hs-identifier hs-var">imp_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163140"><span class="hs-identifier hs-var">exp_tvs</span></a></span><span>
</span><span id="line-898"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163112"><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681163112"><span class="hs-identifier hs-var">dvs</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; TcM CandidatesQTvs
</span><a href="GHC.Tc.Utils.TcMType.html#candidateQTyVarsOfTypes"><span class="hs-identifier hs-var">candidateQTyVarsOfTypes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163138"><span class="hs-identifier hs-var">lhs_ty</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; [PredType] -&gt; [PredType]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [PredType]
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTys"><span class="hs-identifier hs-var">mkTyVarTys</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163113"><span class="hs-identifier hs-var">scoped_tvs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-899"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163110"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163110"><span class="hs-identifier hs-var">qtvs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs -&gt; TcM [Id]
</span><a href="GHC.Tc.Utils.TcMType.html#quantifyTyVars"><span class="hs-identifier hs-var">quantifyTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">CandidatesQTvs
</span><a href="#local-6989586621681163112"><span class="hs-identifier hs-var">dvs</span></a></span><span>
</span><span id="line-900"></span><span>
</span><span id="line-901"></span><span>       </span><span class="hs-comment">-- Zonk the patterns etc into the Type world</span><span>
</span><span id="line-902"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163108"><span class="annot"><span class="annottext">ZonkEnv
</span><a href="#local-6989586621681163108"><span class="hs-identifier hs-var">ze</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163107"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163107"><span class="hs-identifier hs-var">qtvs</span></a></span></span><span class="hs-special">)</span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; TcM (ZonkEnv, [Id])
</span><a href="GHC.Tc.Utils.Zonk.html#zonkTyBndrs"><span class="hs-identifier hs-var">zonkTyBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163110"><span class="hs-identifier hs-var">qtvs</span></a></span><span>
</span><span id="line-903"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163105"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163105"><span class="hs-identifier hs-var">lhs_ty</span></a></span></span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ZonkEnv -&gt; PredType -&gt; TcM PredType
</span><a href="GHC.Tc.Utils.Zonk.html#zonkTcTypeToTypeX"><span class="hs-identifier hs-var">zonkTcTypeToTypeX</span></a></span><span> </span><span class="annot"><span class="annottext">ZonkEnv
</span><a href="#local-6989586621681163108"><span class="hs-identifier hs-var">ze</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163138"><span class="hs-identifier hs-var">lhs_ty</span></a></span><span>
</span><span id="line-904"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163103"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163103"><span class="hs-identifier hs-var">stupid_theta</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ZonkEnv -&gt; [PredType] -&gt; TcM [PredType]
</span><a href="GHC.Tc.Utils.Zonk.html#zonkTcTypesToTypesX"><span class="hs-identifier hs-var">zonkTcTypesToTypesX</span></a></span><span> </span><span class="annot"><span class="annottext">ZonkEnv
</span><a href="#local-6989586621681163108"><span class="hs-identifier hs-var">ze</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163139"><span class="hs-identifier hs-var">stupid_theta</span></a></span><span>
</span><span id="line-905"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163101"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163101"><span class="hs-identifier hs-var">master_res_kind</span></a></span></span><span>   </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ZonkEnv -&gt; PredType -&gt; TcM PredType
</span><a href="GHC.Tc.Utils.Zonk.html#zonkTcTypeToTypeX"><span class="hs-identifier hs-var">zonkTcTypeToTypeX</span></a></span><span> </span><span class="annot"><span class="annottext">ZonkEnv
</span><a href="#local-6989586621681163108"><span class="hs-identifier hs-var">ze</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163137"><span class="hs-identifier hs-var">master_res_kind</span></a></span><span>
</span><span id="line-906"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163100"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163100"><span class="hs-identifier hs-var">instance_res_kind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">ZonkEnv -&gt; PredType -&gt; TcM PredType
</span><a href="GHC.Tc.Utils.Zonk.html#zonkTcTypeToTypeX"><span class="hs-identifier hs-var">zonkTcTypeToTypeX</span></a></span><span> </span><span class="annot"><span class="annottext">ZonkEnv
</span><a href="#local-6989586621681163108"><span class="hs-identifier hs-var">ze</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163136"><span class="hs-identifier hs-var">instance_res_kind</span></a></span><span>
</span><span id="line-907"></span><span>
</span><span id="line-908"></span><span>       </span><span class="hs-comment">-- We check that res_kind is OK with checkDataKindSig in</span><span>
</span><span id="line-909"></span><span>       </span><span class="hs-comment">-- tcDataFamInstDecl, after eta-expansion.  We need to check that</span><span>
</span><span id="line-910"></span><span>       </span><span class="hs-comment">-- it's ok because res_kind can come from a user-written kind signature.</span><span>
</span><span id="line-911"></span><span>       </span><span class="hs-comment">-- See Note [Datatype return kinds], point (4a)</span><span>
</span><span id="line-912"></span><span>
</span><span id="line-913"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">DataSort -&gt; PredType -&gt; TcRn ()
</span><a href="GHC.Tc.Gen.HsType.html#checkDataKindSig"><span class="hs-identifier hs-var">checkDataKindSig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NewOrData -&gt; DataSort
</span><a href="GHC.Tc.Gen.HsType.html#DataInstanceSort"><span class="hs-identifier hs-var">DataInstanceSort</span></a></span><span> </span><span class="annot"><span class="annottext">NewOrData
</span><a href="#local-6989586621681163142"><span class="hs-identifier hs-var">new_or_data</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163101"><span class="hs-identifier hs-var">master_res_kind</span></a></span><span>
</span><span id="line-914"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">DataSort -&gt; PredType -&gt; TcRn ()
</span><a href="GHC.Tc.Gen.HsType.html#checkDataKindSig"><span class="hs-identifier hs-var">checkDataKindSig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NewOrData -&gt; DataSort
</span><a href="GHC.Tc.Gen.HsType.html#DataInstanceSort"><span class="hs-identifier hs-var">DataInstanceSort</span></a></span><span> </span><span class="annot"><span class="annottext">NewOrData
</span><a href="#local-6989586621681163142"><span class="hs-identifier hs-var">new_or_data</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163100"><span class="hs-identifier hs-var">instance_res_kind</span></a></span><span>
</span><span id="line-915"></span><span>
</span><span id="line-916"></span><span>       </span><span class="hs-comment">-- Check that type patterns match the class instance head</span><span>
</span><span id="line-917"></span><span>       </span><span class="hs-comment">-- The call to splitTyConApp_maybe here is just an inlining of</span><span>
</span><span id="line-918"></span><span>       </span><span class="hs-comment">-- the body of unravelFamInstPats.</span><span>
</span><span id="line-919"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163097"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163097"><span class="hs-identifier hs-var">pats</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; PredType -&gt; Maybe (TyCon, [PredType])
PredType -&gt; Maybe (TyCon, [PredType])
</span><a href="GHC.Core.Type.html#splitTyConApp_maybe"><span class="hs-identifier hs-var">splitTyConApp_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163105"><span class="hs-identifier hs-var">lhs_ty</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-920"></span><span>           </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163095"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163095"><span class="hs-identifier hs-var">pats</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; TcM [PredType]
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163095"><span class="hs-identifier hs-var">pats</span></a></span><span>
</span><span id="line-921"></span><span>           </span><span class="annot"><span class="annottext">Maybe (TyCon, [PredType])
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcM [PredType]
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcDataFamInstHeader&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163105"><span class="hs-identifier hs-var">lhs_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-922"></span><span>
</span><span id="line-923"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([Id], [PredType], PredType, [PredType])
-&gt; TcM ([Id], [PredType], PredType, [PredType])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163107"><span class="hs-identifier hs-var">qtvs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163097"><span class="hs-identifier hs-var">pats</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163101"><span class="hs-identifier hs-var">master_res_kind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163103"><span class="hs-identifier hs-var">stupid_theta</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-924"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-925"></span><span>    </span><span id="local-6989586621681163093"><span class="annot"><span class="annottext">fam_name :: Name
</span><a href="#local-6989586621681163093"><span class="hs-identifier hs-var hs-var">fam_name</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163150"><span class="hs-identifier hs-var">fam_tc</span></a></span><span>
</span><span id="line-926"></span><span>    </span><span id="local-6989586621681163091"><span class="annot"><span class="annottext">data_ctxt :: UserTypeCtxt
</span><a href="#local-6989586621681163091"><span class="hs-identifier hs-var hs-var">data_ctxt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#DataKindCtxt"><span class="hs-identifier hs-var">DataKindCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681163093"><span class="hs-identifier hs-var">fam_name</span></a></span><span>
</span><span id="line-927"></span><span>    </span><span id="local-6989586621681163130"><span class="annot"><span class="annottext">exp_bndrs :: [LHsTyVarBndr () (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163130"><span class="hs-identifier hs-var hs-var">exp_bndrs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe [LHsTyVarBndr () (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163148"><span class="hs-identifier hs-var">mb_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe [LHsTyVarBndr () (GhcPass 'Renamed)]
-&gt; [LHsTyVarBndr () (GhcPass 'Renamed)]
-&gt; [LHsTyVarBndr () (GhcPass 'Renamed)]
forall a. Maybe a -&gt; a -&gt; a
</span><a href="GHC.Data.Maybe.html#orElse"><span class="hs-operator hs-var">`orElse`</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-928"></span><span>
</span><span id="line-929"></span><span>    </span><span class="hs-comment">-- See Note [Implementation of UnliftedNewtypes] in GHC.Tc.TyCl, wrinkle (2).</span><span>
</span><span id="line-930"></span><span>    </span><span id="local-6989586621681163119"><span class="annot"><span class="annottext">tc_kind_sig :: Maybe (LHsType (GhcPass 'Renamed)) -&gt; TcM PredType
</span><a href="#local-6989586621681163119"><span class="hs-identifier hs-var hs-var">tc_kind_sig</span></a></span></span><span> </span><span class="annot"><span class="annottext">Maybe (LHsType (GhcPass 'Renamed))
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-931"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681163088"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681163088"><span class="hs-identifier hs-var">unlifted_newtypes</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRn Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#UnliftedNewtypes"><span class="hs-identifier hs-var">LangExt.UnliftedNewtypes</span></a></span><span>
</span><span id="line-932"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681163088"><span class="hs-identifier hs-var">unlifted_newtypes</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">NewOrData
</span><a href="#local-6989586621681163142"><span class="hs-identifier hs-var">new_or_data</span></a></span><span> </span><span class="annot"><span class="annottext">NewOrData -&gt; NewOrData -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">NewOrData
</span><a href="GHC.Hs.Decls.html#NewType"><span class="hs-identifier hs-var">NewType</span></a></span><span>
</span><span id="line-933"></span><span>               </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">TcM PredType
</span><a href="GHC.Tc.Utils.TcMType.html#newOpenTypeKind"><span class="hs-identifier hs-var">newOpenTypeKind</span></a></span><span>
</span><span id="line-934"></span><span>               </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; TcM PredType
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">pure</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="GHC.Builtin.Types.html#liftedTypeKind"><span class="hs-identifier hs-var">liftedTypeKind</span></a></span><span>
</span><span id="line-935"></span><span>           </span><span class="hs-special">}</span><span>
</span><span id="line-936"></span><span>
</span><span id="line-937"></span><span>    </span><span class="hs-comment">-- See Note [Result kind signature for a data family instance]</span><span>
</span><span id="line-938"></span><span>    </span><span class="annot"><a href="#local-6989586621681163119"><span class="hs-identifier hs-var">tc_kind_sig</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681163084"><span class="annot"><span class="annottext">LHsType (GhcPass 'Renamed)
</span><a href="#local-6989586621681163084"><span class="hs-identifier hs-var">hs_kind</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-939"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681163083"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163083"><span class="hs-identifier hs-var">sig_kind</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; LHsType (GhcPass 'Renamed) -&gt; TcM PredType
</span><a href="GHC.Tc.Gen.HsType.html#tcLHsKindSig"><span class="hs-identifier hs-var">tcLHsKindSig</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681163091"><span class="hs-identifier hs-var">data_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">LHsType (GhcPass 'Renamed)
</span><a href="#local-6989586621681163084"><span class="hs-identifier hs-var">hs_kind</span></a></span><span>
</span><span id="line-940"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163081"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163081"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163080"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163080"><span class="hs-identifier hs-var">inner_kind</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; ([Id], PredType)
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitForAllTys"><span class="hs-identifier hs-var">tcSplitForAllTys</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163083"><span class="hs-identifier hs-var">sig_kind</span></a></span><span>
</span><span id="line-941"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163078"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681163078"><span class="hs-identifier hs-var">lvl</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM TcLevel
</span><a href="GHC.Tc.Utils.Monad.html#getTcLevel"><span class="hs-identifier hs-var">getTcLevel</span></a></span><span>
</span><span id="line-942"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163076"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681163076"><span class="hs-identifier hs-var">subst</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163075"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163075"><span class="hs-identifier hs-var">_tvs'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcLevel -&gt; Bool -&gt; TCvSubst -&gt; [Id] -&gt; TcM (TCvSubst, [Id])
</span><a href="GHC.Tc.Utils.Instantiate.html#tcInstSkolTyVarsAt"><span class="hs-identifier hs-var">tcInstSkolTyVarsAt</span></a></span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681163078"><span class="hs-identifier hs-var">lvl</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#emptyTCvSubst"><span class="hs-identifier hs-var">emptyTCvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163081"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-943"></span><span>             </span><span class="hs-comment">-- Perhaps surprisingly, we don't need the skolemised tvs themselves</span><span>
</span><span id="line-944"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; TcM PredType
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; PredType -&gt; PredType
TCvSubst -&gt; PredType -&gt; PredType
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681163076"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163080"><span class="hs-identifier hs-var">inner_kind</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-945"></span><span>
</span><span id="line-946"></span><span class="hs-comment">{- Note [Result kind signature for a data family instance]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The expected type might have a forall at the type. Normally, we
can't skolemise in kinds because we don't have type-level lambda.
But here, we're at the top-level of an instance declaration, so
we actually have a place to put the regeneralised variables.
Thus: skolemise away. cf. GHC.Tc.Utils.Unify.tcSkolemise
Examples in indexed-types/should_compile/T12369

Note [Implementing eta reduction for data families]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider
   data D :: * -&gt; * -&gt; * -&gt; * -&gt; *

   data instance D [(a,b)] p q :: * -&gt; * where
      D1 :: blah1
      D2 :: blah2

Then we'll generate a representation data type
  data Drep a b p q z where
      D1 :: blah1
      D2 :: blah2

and an axiom to connect them
  axiom AxDrep forall a b p q z. D [(a,b]] p q z = Drep a b p q z

except that we'll eta-reduce the axiom to
  axiom AxDrep forall a b. D [(a,b]] = Drep a b

This is described at some length in Note [Eta reduction for data families]
in GHC.Core.Coercion.Axiom. There are several fiddly subtleties lurking here,
however, so this Note aims to describe these subtleties:

* The representation tycon Drep is parameterised over the free
  variables of the pattern, in no particular order. So there is no
  guarantee that 'p' and 'q' will come last in Drep's parameters, and
  in the right order.  So, if the /patterns/ of the family instance
  are eta-reducible, we re-order Drep's parameters to put the
  eta-reduced type variables last.

* Although we eta-reduce the axiom, we eta-/expand/ the representation
  tycon Drep.  The kind of D says it takes four arguments, but the
  data instance header only supplies three.  But the AlgTyCon for Drep
  itself must have enough TyConBinders so that its result kind is Type.
  So, with etaExpandAlgTyCon we make up some extra TyConBinders.
  See point (3) in Note [Datatype return kinds] in GHC.Tc.TyCl.

* The result kind in the instance might be a polykind, like this:
     data family DP a :: forall k. k -&gt; *
     data instance DP [b] :: forall k1 k2. (k1,k2) -&gt; *

  So in type-checking the LHS (DP Int) we need to check that it is
  more polymorphic than the signature.  To do that we must skolemise
  the signature and instantiate the call of DP.  So we end up with
     data instance DP [b] @(k1,k2) (z :: (k1,k2)) where

  Note that we must parameterise the representation tycon DPrep over
  'k1' and 'k2', as well as 'b'.

  The skolemise bit is done in tc_kind_sig, while the instantiate bit
  is done by tcFamTyPats.

* Very fiddly point.  When we eta-reduce to
     axiom AxDrep forall a b. D [(a,b]] = Drep a b

  we want the kind of (D [(a,b)]) to be the same as the kind of
  (Drep a b).  This ensures that applying the axiom doesn't change the
  kind.  Why is that hard?  Because the kind of (Drep a b) depends on
  the TyConBndrVis on Drep's arguments. In particular do we have
    (forall (k::*). blah) or (* -&gt; blah)?

  We must match whatever D does!  In #15817 we had
      data family X a :: forall k. * -&gt; *   -- Note: a forall that is not used
      data instance X Int b = MkX

  So the data instance is really
      data istance X Int @k b = MkX

  The axiom will look like
      axiom    X Int = Xrep

  and it's important that XRep :: forall k * -&gt; *, following X.

  To achieve this we get the TyConBndrVis flags from tcbVisibilities,
  and use those flags for any eta-reduced arguments.  Sigh.

* The final turn of the knife is that tcbVisibilities is itself
  tricky to sort out.  Consider
      data family D k :: k
  Then consider D (forall k2. k2 -&gt; k2) Type Type
  The visibility flags on an application of D may affected by the arguments
  themselves.  Heavy sigh.  But not truly hard; that's what tcbVisibilities
  does.

-}</span><span>
</span><span id="line-1041"></span><span>
</span><span id="line-1042"></span><span>
</span><span id="line-1043"></span><span class="hs-comment">{- *********************************************************************
*                                                                      *
      Class instance declarations, pass 2
*                                                                      *
********************************************************************* -}</span><span>
</span><span id="line-1048"></span><span>
</span><span id="line-1049"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcInstDecls2"><span class="hs-identifier hs-type">tcInstDecls2</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Decls.html#LTyClDecl"><span class="hs-identifier hs-type">LTyClDecl</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1050"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1051"></span><span class="hs-comment">-- (a) From each class declaration,</span><span>
</span><span id="line-1052"></span><span class="hs-comment">--      generate any default-method bindings</span><span>
</span><span id="line-1053"></span><span class="hs-comment">-- (b) From each instance decl</span><span>
</span><span id="line-1054"></span><span class="hs-comment">--      generate the dfun binding</span><span>
</span><span id="line-1055"></span><span>
</span><span id="line-1056"></span><span id="tcInstDecls2"><span class="annot"><span class="annottext">tcInstDecls2 :: [LTyClDecl (GhcPass 'Renamed)]
-&gt; [InstInfo (GhcPass 'Renamed)] -&gt; TcM (LHsBinds GhcTc)
</span><a href="GHC.Tc.TyCl.Instance.html#tcInstDecls2"><span class="hs-identifier hs-var hs-var">tcInstDecls2</span></a></span></span><span> </span><span id="local-6989586621681163071"><span class="annot"><span class="annottext">[LTyClDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163071"><span class="hs-identifier hs-var">tycl_decls</span></a></span></span><span> </span><span id="local-6989586621681163070"><span class="annot"><span class="annottext">[InstInfo (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163070"><span class="hs-identifier hs-var">inst_decls</span></a></span></span><span>
</span><span id="line-1057"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- (a) Default methods from class decls</span><span>
</span><span id="line-1058"></span><span>          </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163069"><span class="annot"><span class="annottext">class_decls :: [LTyClDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163069"><span class="hs-identifier hs-var hs-var">class_decls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LTyClDecl (GhcPass 'Renamed) -&gt; Bool)
-&gt; [LTyClDecl (GhcPass 'Renamed)] -&gt; [LTyClDecl (GhcPass 'Renamed)]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyClDecl (GhcPass 'Renamed) -&gt; Bool
forall pass. TyClDecl pass -&gt; Bool
</span><a href="GHC.Hs.Decls.html#isClassDecl"><span class="hs-identifier hs-var">isClassDecl</span></a></span><span> </span><span class="annot"><span class="annottext">(TyClDecl (GhcPass 'Renamed) -&gt; Bool)
-&gt; (LTyClDecl (GhcPass 'Renamed) -&gt; TyClDecl (GhcPass 'Renamed))
-&gt; LTyClDecl (GhcPass 'Renamed)
-&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">LTyClDecl (GhcPass 'Renamed) -&gt; TyClDecl (GhcPass 'Renamed)
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[LTyClDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163071"><span class="hs-identifier hs-var">tycl_decls</span></a></span><span>
</span><span id="line-1059"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163067"><span class="annot"><span class="annottext">[LHsBinds GhcTc]
</span><a href="#local-6989586621681163067"><span class="hs-identifier hs-var">dm_binds_s</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(LTyClDecl (GhcPass 'Renamed) -&gt; TcM (LHsBinds GhcTc))
-&gt; [LTyClDecl (GhcPass 'Renamed)]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [LHsBinds GhcTc]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">LTyClDecl (GhcPass 'Renamed) -&gt; TcM (LHsBinds GhcTc)
</span><a href="GHC.Tc.TyCl.Class.html#tcClassDecl2"><span class="hs-identifier hs-var">tcClassDecl2</span></a></span><span> </span><span class="annot"><span class="annottext">[LTyClDecl (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163069"><span class="hs-identifier hs-var">class_decls</span></a></span><span>
</span><span id="line-1060"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163066"><span class="annot"><span class="annottext">dm_binds :: LHsBinds GhcTc
</span><a href="#local-6989586621681163066"><span class="hs-identifier hs-var hs-var">dm_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LHsBinds GhcTc] -&gt; LHsBinds GhcTc
forall a. [Bag a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionManyBags"><span class="hs-identifier hs-var">unionManyBags</span></a></span><span> </span><span class="annot"><span class="annottext">[LHsBinds GhcTc]
</span><a href="#local-6989586621681163067"><span class="hs-identifier hs-var">dm_binds_s</span></a></span><span>
</span><span id="line-1061"></span><span>
</span><span id="line-1062"></span><span>          </span><span class="hs-comment">-- (b) instance declarations</span><span>
</span><span id="line-1063"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163064"><span class="annot"><span class="annottext">dm_ids :: [IdP GhcTc]
</span><a href="#local-6989586621681163064"><span class="hs-identifier hs-var hs-var">dm_ids</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc -&gt; [IdP GhcTc]
forall p idR. CollectPass p =&gt; LHsBindsLR p idR -&gt; [IdP p]
</span><a href="GHC.Hs.Utils.html#collectHsBindsBinders"><span class="hs-identifier hs-var">collectHsBindsBinders</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681163066"><span class="hs-identifier hs-var">dm_binds</span></a></span><span>
</span><span id="line-1064"></span><span>              </span><span class="hs-comment">-- Add the default method Ids (again)</span><span>
</span><span id="line-1065"></span><span>              </span><span class="hs-comment">-- (they were arready added in GHC.Tc.TyCl.Utils.tcAddImplicits)</span><span>
</span><span id="line-1066"></span><span>              </span><span class="hs-comment">-- See Note [Default methods in the type environment]</span><span>
</span><span id="line-1067"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163062"><span class="annot"><span class="annottext">[LHsBinds GhcTc]
</span><a href="#local-6989586621681163062"><span class="hs-identifier hs-var">inst_binds_s</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [LHsBinds GhcTc]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [LHsBinds GhcTc]
forall r. [Id] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendGlobalValEnv"><span class="hs-identifier hs-var">tcExtendGlobalValEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
[IdP GhcTc]
</span><a href="#local-6989586621681163064"><span class="hs-identifier hs-var">dm_ids</span></a></span><span> </span><span class="annot"><span class="annottext">(IOEnv (Env TcGblEnv TcLclEnv) [LHsBinds GhcTc]
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) [LHsBinds GhcTc])
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [LHsBinds GhcTc]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [LHsBinds GhcTc]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1068"></span><span>                          </span><span class="annot"><span class="annottext">(InstInfo (GhcPass 'Renamed) -&gt; TcM (LHsBinds GhcTc))
-&gt; [InstInfo (GhcPass 'Renamed)]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) [LHsBinds GhcTc]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="annot"><span class="annottext">InstInfo (GhcPass 'Renamed) -&gt; TcM (LHsBinds GhcTc)
</span><a href="GHC.Tc.TyCl.Instance.html#tcInstDecl2"><span class="hs-identifier hs-var">tcInstDecl2</span></a></span><span> </span><span class="annot"><span class="annottext">[InstInfo (GhcPass 'Renamed)]
</span><a href="#local-6989586621681163070"><span class="hs-identifier hs-var">inst_decls</span></a></span><span>
</span><span id="line-1069"></span><span>
</span><span id="line-1070"></span><span>          </span><span class="hs-comment">-- Done</span><span>
</span><span id="line-1071"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc -&gt; TcM (LHsBinds GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681163066"><span class="hs-identifier hs-var">dm_binds</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc -&gt; LHsBinds GhcTc -&gt; LHsBinds GhcTc
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">[LHsBinds GhcTc] -&gt; LHsBinds GhcTc
forall a. [Bag a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionManyBags"><span class="hs-identifier hs-var">unionManyBags</span></a></span><span> </span><span class="annot"><span class="annottext">[LHsBinds GhcTc]
</span><a href="#local-6989586621681163062"><span class="hs-identifier hs-var">inst_binds_s</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1072"></span><span>
</span><span id="line-1073"></span><span class="hs-comment">{- Note [Default methods in the type environment]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The default method Ids are already in the type environment (see Note
[Default method Ids and Template Haskell] in TcTyDcls), BUT they
don't have their InlinePragmas yet.  Usually that would not matter,
because the simplifier propagates information from binding site to
use.  But, unusually, when compiling instance decls we *copy* the
INLINE pragma from the default method to the method for that
particular operation (see Note [INLINE and default methods] below).

So right here in tcInstDecls2 we must re-extend the type envt with
the default method Ids replete with their INLINE pragmas.  Urk.
-}</span><span>
</span><span id="line-1086"></span><span>
</span><span id="line-1087"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcInstDecl2"><span class="hs-identifier hs-type">tcInstDecl2</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1088"></span><span>            </span><span class="hs-comment">-- Returns a binding for the dfun</span><span>
</span><span id="line-1089"></span><span id="tcInstDecl2"><span class="annot"><span class="annottext">tcInstDecl2 :: InstInfo (GhcPass 'Renamed) -&gt; TcM (LHsBinds GhcTc)
</span><a href="GHC.Tc.TyCl.Instance.html#tcInstDecl2"><span class="hs-identifier hs-var hs-var">tcInstDecl2</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstInfo"><span class="hs-identifier hs-type">InstInfo</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">iSpec :: forall a. InstInfo a -&gt; ClsInst
</span><a href="GHC.Tc.Utils.Env.html#iSpec"><span class="hs-identifier hs-var">iSpec</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163058"><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681163058"><span class="hs-identifier hs-var">ispec</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">iBinds :: forall a. InstInfo a -&gt; InstBindings a
</span><a href="GHC.Tc.Utils.Env.html#iBinds"><span class="hs-identifier hs-var">iBinds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681163057"><span class="annot"><span class="annottext">InstBindings (GhcPass 'Renamed)
</span><a href="#local-6989586621681163057"><span class="hs-identifier hs-var">ibinds</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1090"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcM (LHsBinds GhcTc)
-&gt; TcM (LHsBinds GhcTc) -&gt; TcM (LHsBinds GhcTc)
forall r. TcRn r -&gt; TcRn r -&gt; TcRn r
</span><a href="GHC.Tc.Utils.Monad.html#recoverM"><span class="hs-identifier hs-var">recoverM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsBinds GhcTc -&gt; TcM (LHsBinds GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc
forall idL idR. LHsBindsLR idL idR
</span><a href="GHC.Hs.Binds.html#emptyLHsBinds"><span class="hs-identifier hs-var">emptyLHsBinds</span></a></span><span class="hs-special">)</span><span>             </span><span class="annot"><span class="annottext">(TcM (LHsBinds GhcTc) -&gt; TcM (LHsBinds GhcTc))
-&gt; TcM (LHsBinds GhcTc) -&gt; TcM (LHsBinds GhcTc)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1091"></span><span>    </span><span class="annot"><span class="annottext">SrcSpan -&gt; TcM (LHsBinds GhcTc) -&gt; TcM (LHsBinds GhcTc)
forall a. SrcSpan -&gt; TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#setSrcSpan"><span class="hs-identifier hs-var">setSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163054"><span class="hs-identifier hs-var">loc</span></a></span><span>                              </span><span class="annot"><span class="annottext">(TcM (LHsBinds GhcTc) -&gt; TcM (LHsBinds GhcTc))
-&gt; TcM (LHsBinds GhcTc) -&gt; TcM (LHsBinds GhcTc)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1092"></span><span>    </span><span class="annot"><span class="annottext">SDoc -&gt; TcM (LHsBinds GhcTc) -&gt; TcM (LHsBinds GhcTc)
forall a. SDoc -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#addErrCtxt"><span class="hs-identifier hs-var">addErrCtxt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#instDeclCtxt2"><span class="hs-identifier hs-var">instDeclCtxt2</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163051"><span class="hs-identifier hs-var">dfun_id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcM (LHsBinds GhcTc) -&gt; TcM (LHsBinds GhcTc))
-&gt; TcM (LHsBinds GhcTc) -&gt; TcM (LHsBinds GhcTc)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1093"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span>  </span><span class="hs-comment">-- Instantiate the instance decl with skolem constants</span><span>
</span><span id="line-1094"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163050"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163050"><span class="hs-identifier hs-var">inst_tyvars</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163049"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163049"><span class="hs-identifier hs-var">dfun_theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163048"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163048"><span class="hs-identifier hs-var">inst_head</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; TcM ([Id], [PredType], PredType)
</span><a href="GHC.Tc.Utils.Instantiate.html#tcSkolDFunType"><span class="hs-identifier hs-var">tcSkolDFunType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163051"><span class="hs-identifier hs-var">dfun_id</span></a></span><span>
</span><span id="line-1095"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163046"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163046"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; TcM [Id]
</span><a href="GHC.Tc.Utils.TcMType.html#newEvVars"><span class="hs-identifier hs-var">newEvVars</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163049"><span class="hs-identifier hs-var">dfun_theta</span></a></span><span>
</span><span id="line-1096"></span><span>                     </span><span class="hs-comment">-- We instantiate the dfun_id with superSkolems.</span><span>
</span><span id="line-1097"></span><span>                     </span><span class="hs-comment">-- See Note [Subtle interaction of recursion and overlap]</span><span>
</span><span id="line-1098"></span><span>                     </span><span class="hs-comment">-- and Note [Binding when looking up instances]</span><span>
</span><span id="line-1099"></span><span>
</span><span id="line-1100"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163044"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163044"><span class="hs-identifier hs-var">clas</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163043"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163043"><span class="hs-identifier hs-var">inst_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; (Class, [PredType])
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitDFunHead"><span class="hs-identifier hs-var">tcSplitDFunHead</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681163048"><span class="hs-identifier hs-var">inst_head</span></a></span><span>
</span><span id="line-1101"></span><span>             </span><span class="hs-special">(</span><span id="local-6989586621681163041"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163041"><span class="hs-identifier hs-var">class_tyvars</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163040"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163040"><span class="hs-identifier hs-var">sc_theta</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163039"><span class="annot"><span class="annottext">[ClassOpItem]
</span><a href="#local-6989586621681163039"><span class="hs-identifier hs-var">op_items</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; ([Id], [PredType], [Id], [ClassOpItem])
</span><a href="GHC.Core.Class.html#classBigSig"><span class="hs-identifier hs-var">classBigSig</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163044"><span class="hs-identifier hs-var">clas</span></a></span><span>
</span><span id="line-1102"></span><span>             </span><span id="local-6989586621681163037"><span class="annot"><span class="annottext">sc_theta' :: [PredType]
</span><a href="#local-6989586621681163037"><span class="hs-identifier hs-var hs-var">sc_theta'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; [PredType] -&gt; [PredType]
TCvSubst -&gt; [PredType] -&gt; [PredType]
</span><a href="GHC.Core.TyCo.Subst.html#substTheta"><span class="hs-identifier hs-var">substTheta</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id] -&gt; [PredType] -&gt; TCvSubst
HasDebugCallStack =&gt; [Id] -&gt; [PredType] -&gt; TCvSubst
</span><a href="GHC.Core.TyCo.Subst.html#zipTvSubst"><span class="hs-identifier hs-var">zipTvSubst</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163041"><span class="hs-identifier hs-var">class_tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163043"><span class="hs-identifier hs-var">inst_tys</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163040"><span class="hs-identifier hs-var">sc_theta</span></a></span><span>
</span><span id="line-1103"></span><span>
</span><span id="line-1104"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcInstDecl2&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">[Id] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163050"><span class="hs-identifier hs-var">inst_tyvars</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163043"><span class="hs-identifier hs-var">inst_tys</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163049"><span class="hs-identifier hs-var">dfun_theta</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163037"><span class="hs-identifier hs-var">sc_theta'</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1105"></span><span>
</span><span id="line-1106"></span><span>                      </span><span class="hs-comment">-- Deal with 'SPECIALISE instance' pragmas</span><span>
</span><span id="line-1107"></span><span>                      </span><span class="hs-comment">-- See Note [SPECIALISE instance pragmas]</span><span>
</span><span id="line-1108"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163034"><span class="annot"><span class="annottext">spec_inst_info :: ([Located TcSpecPrag], TcPragEnv)
</span><a href="#local-6989586621681163034"><span class="hs-identifier hs-var">spec_inst_info</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621681163033"><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681163033"><span class="hs-identifier hs-var">spec_inst_prags</span></a></span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">TcPragEnv
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; InstBindings (GhcPass 'Renamed)
-&gt; TcM ([Located TcSpecPrag], TcPragEnv)
</span><a href="GHC.Tc.TyCl.Instance.html#tcSpecInstPrags"><span class="hs-identifier hs-var">tcSpecInstPrags</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163051"><span class="hs-identifier hs-var">dfun_id</span></a></span><span> </span><span class="annot"><span class="annottext">InstBindings (GhcPass 'Renamed)
</span><a href="#local-6989586621681163057"><span class="hs-identifier hs-var">ibinds</span></a></span><span>
</span><span id="line-1109"></span><span>
</span><span id="line-1110"></span><span>         </span><span class="hs-comment">-- Typecheck superclasses and methods</span><span>
</span><span id="line-1111"></span><span>         </span><span class="hs-comment">-- See Note [Typechecking plan for instance declarations]</span><span>
</span><span id="line-1112"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163031"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681163031"><span class="hs-identifier hs-var">dfun_ev_binds_var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM EvBindsVar
</span><a href="GHC.Tc.Utils.Monad.html#newTcEvBinds"><span class="hs-identifier hs-var">newTcEvBinds</span></a></span><span>
</span><span id="line-1113"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163029"><span class="annot"><span class="annottext">dfun_ev_binds :: TcEvBinds
</span><a href="#local-6989586621681163029"><span class="hs-identifier hs-var hs-var">dfun_ev_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcEvBinds
</span><a href="GHC.Tc.Types.Evidence.html#TcEvBinds"><span class="hs-identifier hs-var">TcEvBinds</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681163031"><span class="hs-identifier hs-var">dfun_ev_binds_var</span></a></span><span>
</span><span id="line-1114"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163027"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681163027"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163026"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163026"><span class="hs-identifier hs-var">sc_meth_ids</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163025"><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681163025"><span class="hs-identifier hs-var">sc_meth_binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163024"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681163024"><span class="hs-identifier hs-var">sc_meth_implics</span></a></span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1115"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM ([Id], LHsBinds GhcTc, Bag Implication)
-&gt; TcM (TcLevel, ([Id], LHsBinds GhcTc, Bag Implication))
forall a. TcM a -&gt; TcM (TcLevel, a)
</span><a href="GHC.Tc.Utils.Monad.html#pushTcLevelM"><span class="hs-identifier hs-var">pushTcLevelM</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM ([Id], LHsBinds GhcTc, Bag Implication)
 -&gt; TcM (TcLevel, ([Id], LHsBinds GhcTc, Bag Implication)))
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
-&gt; TcM (TcLevel, ([Id], LHsBinds GhcTc, Bag Implication))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1116"></span><span>                </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163022"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163022"><span class="hs-identifier hs-var">sc_ids</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163021"><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681163021"><span class="hs-identifier hs-var">sc_binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163020"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681163020"><span class="hs-identifier hs-var">sc_implics</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1117"></span><span>                        </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; Class
-&gt; [Id]
-&gt; [Id]
-&gt; [PredType]
-&gt; TcEvBinds
-&gt; [PredType]
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
</span><a href="GHC.Tc.TyCl.Instance.html#tcSuperClasses"><span class="hs-identifier hs-var">tcSuperClasses</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163051"><span class="hs-identifier hs-var">dfun_id</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163044"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163050"><span class="hs-identifier hs-var">inst_tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163046"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span>
</span><span id="line-1118"></span><span>                                          </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163043"><span class="hs-identifier hs-var">inst_tys</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681163029"><span class="hs-identifier hs-var">dfun_ev_binds</span></a></span><span>
</span><span id="line-1119"></span><span>                                          </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163037"><span class="hs-identifier hs-var">sc_theta'</span></a></span><span>
</span><span id="line-1120"></span><span>
</span><span id="line-1121"></span><span>                      </span><span class="hs-comment">-- Typecheck the methods</span><span>
</span><span id="line-1122"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681163018"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163018"><span class="hs-identifier hs-var">meth_ids</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163017"><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681163017"><span class="hs-identifier hs-var">meth_binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681163016"><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681163016"><span class="hs-identifier hs-var">meth_implics</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1123"></span><span>                        </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; Class
-&gt; [Id]
-&gt; [Id]
-&gt; [PredType]
-&gt; TcEvBinds
-&gt; ([Located TcSpecPrag], TcPragEnv)
-&gt; [ClassOpItem]
-&gt; InstBindings (GhcPass 'Renamed)
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
</span><a href="GHC.Tc.TyCl.Instance.html#tcMethods"><span class="hs-identifier hs-var">tcMethods</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163051"><span class="hs-identifier hs-var">dfun_id</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163044"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163050"><span class="hs-identifier hs-var">inst_tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163046"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span>
</span><span id="line-1124"></span><span>                                     </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163043"><span class="hs-identifier hs-var">inst_tys</span></a></span><span> </span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681163029"><span class="hs-identifier hs-var">dfun_ev_binds</span></a></span><span> </span><span class="annot"><span class="annottext">([Located TcSpecPrag], TcPragEnv)
</span><a href="#local-6989586621681163034"><span class="hs-identifier hs-var">spec_inst_info</span></a></span><span>
</span><span id="line-1125"></span><span>                                     </span><span class="annot"><span class="annottext">[ClassOpItem]
</span><a href="#local-6989586621681163039"><span class="hs-identifier hs-var">op_items</span></a></span><span> </span><span class="annot"><span class="annottext">InstBindings (GhcPass 'Renamed)
</span><a href="#local-6989586621681163057"><span class="hs-identifier hs-var">ibinds</span></a></span><span>
</span><span id="line-1126"></span><span>
</span><span id="line-1127"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([Id], LHsBinds GhcTc, Bag Implication)
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163022"><span class="hs-identifier hs-var">sc_ids</span></a></span><span>     </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>          </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163018"><span class="hs-identifier hs-var">meth_ids</span></a></span><span>
</span><span id="line-1128"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681163021"><span class="hs-identifier hs-var">sc_binds</span></a></span><span>   </span><span class="annot"><span class="annottext">LHsBinds GhcTc -&gt; LHsBinds GhcTc -&gt; LHsBinds GhcTc
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681163017"><span class="hs-identifier hs-var">meth_binds</span></a></span><span>
</span><span id="line-1129"></span><span>                            </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681163020"><span class="hs-identifier hs-var">sc_implics</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication -&gt; Bag Implication -&gt; Bag Implication
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681163016"><span class="hs-identifier hs-var">meth_implics</span></a></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1130"></span><span>
</span><span id="line-1131"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163014"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681163014"><span class="hs-identifier hs-var">imp</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM Implication
</span><a href="GHC.Tc.Utils.TcMType.html#newImplication"><span class="hs-identifier hs-var">newImplication</span></a></span><span>
</span><span id="line-1132"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#emitImplication"><span class="hs-identifier hs-var">emitImplication</span></a></span><span> </span><span class="annot"><span class="annottext">(Implication -&gt; TcRn ()) -&gt; Implication -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1133"></span><span>         </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681163014"><span class="hs-identifier hs-var">imp</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_tclvl :: TcLevel
</span><a href="GHC.Tc.Types.Constraint.html#ic_tclvl"><span class="hs-identifier hs-var">ic_tclvl</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681163027"><span class="hs-identifier hs-var">tclvl</span></a></span><span>
</span><span id="line-1134"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_skols :: [Id]
</span><a href="GHC.Tc.Types.Constraint.html#ic_skols"><span class="hs-identifier hs-var">ic_skols</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163050"><span class="hs-identifier hs-var">inst_tyvars</span></a></span><span>
</span><span id="line-1135"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_given :: [Id]
</span><a href="GHC.Tc.Types.Constraint.html#ic_given"><span class="hs-identifier hs-var">ic_given</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163046"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span>
</span><span id="line-1136"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bag Implication -&gt; WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#mkImplicWC"><span class="hs-identifier hs-var">mkImplicWC</span></a></span><span> </span><span class="annot"><span class="annottext">Bag Implication
</span><a href="#local-6989586621681163024"><span class="hs-identifier hs-var">sc_meth_implics</span></a></span><span>
</span><span id="line-1137"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_binds :: EvBindsVar
</span><a href="GHC.Tc.Types.Constraint.html#ic_binds"><span class="hs-identifier hs-var">ic_binds</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681163031"><span class="hs-identifier hs-var">dfun_ev_binds_var</span></a></span><span>
</span><span id="line-1138"></span><span>             </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_info :: SkolemInfo
</span><a href="GHC.Tc.Types.Constraint.html#ic_info"><span class="hs-identifier hs-var">ic_info</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#InstSkol"><span class="hs-identifier hs-var">InstSkol</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1139"></span><span>
</span><span id="line-1140"></span><span>       </span><span class="hs-comment">-- Create the result bindings</span><span>
</span><span id="line-1141"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681163003"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163003"><span class="hs-identifier hs-var">self_dict</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Class -&gt; [PredType] -&gt; TcM Id
</span><a href="GHC.Tc.Utils.TcMType.html#newDict"><span class="hs-identifier hs-var">newDict</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163044"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163043"><span class="hs-identifier hs-var">inst_tys</span></a></span><span>
</span><span id="line-1142"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681163001"><span class="annot"><span class="annottext">class_tc :: TyCon
</span><a href="#local-6989586621681163001"><span class="hs-identifier hs-var hs-var">class_tc</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; TyCon
</span><a href="GHC.Core.Class.html#classTyCon"><span class="hs-identifier hs-var hs-var">classTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681163044"><span class="hs-identifier hs-var">clas</span></a></span><span>
</span><span id="line-1143"></span><span>             </span><span class="hs-special">[</span><span id="local-6989586621681162999"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681162999"><span class="hs-identifier hs-var">dict_constr</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons"><span class="hs-identifier hs-var">tyConDataCons</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163001"><span class="hs-identifier hs-var">class_tc</span></a></span><span>
</span><span id="line-1144"></span><span>             </span><span id="local-6989586621681162997"><span class="annot"><span class="annottext">dict_bind :: LHsBind GhcTc
</span><a href="#local-6989586621681162997"><span class="hs-identifier hs-var hs-var">dict_bind</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdP GhcTc -&gt; LHsExpr GhcTc -&gt; LHsBind GhcTc
forall (p :: Pass).
IdP (GhcPass p) -&gt; LHsExpr (GhcPass p) -&gt; LHsBind (GhcPass p)
</span><a href="GHC.Hs.Utils.html#mkVarBind"><span class="hs-identifier hs-var">mkVarBind</span></a></span><span> </span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681163003"><span class="hs-identifier hs-var">self_dict</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; HsExpr GhcTc -&gt; LHsExpr GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163054"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681162995"><span class="hs-identifier hs-var">con_app_args</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1145"></span><span>
</span><span id="line-1146"></span><span>                     </span><span class="hs-comment">-- We don't produce a binding for the dict_constr; instead we</span><span>
</span><span id="line-1147"></span><span>                     </span><span class="hs-comment">-- rely on the simplifier to unfold this saturated application</span><span>
</span><span id="line-1148"></span><span>                     </span><span class="hs-comment">-- We do this rather than generate an HsCon directly, because</span><span>
</span><span id="line-1149"></span><span>                     </span><span class="hs-comment">-- it means that the special cases (e.g. dictionary with only one</span><span>
</span><span id="line-1150"></span><span>                     </span><span class="hs-comment">-- member) are dealt with by the common MkId.mkDataConWrapId</span><span>
</span><span id="line-1151"></span><span>                     </span><span class="hs-comment">-- code rather than needing to be repeated here.</span><span>
</span><span id="line-1152"></span><span>                     </span><span class="hs-comment">--    con_app_tys  = MkD ty1 ty2</span><span>
</span><span id="line-1153"></span><span>                     </span><span class="hs-comment">--    con_app_scs  = MkD ty1 ty2 sc1 sc2</span><span>
</span><span id="line-1154"></span><span>                     </span><span class="hs-comment">--    con_app_args = MkD ty1 ty2 sc1 sc2 op1 op2</span><span>
</span><span id="line-1155"></span><span>             </span><span id="local-6989586621681162994"><span class="annot"><span class="annottext">con_app_tys :: HsExpr GhcTc
</span><a href="#local-6989586621681162994"><span class="hs-identifier hs-var hs-var">con_app_tys</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsExpr GhcTc -&gt; HsExpr GhcTc
</span><a href="GHC.Hs.Utils.html#mkHsWrap"><span class="hs-identifier hs-var">mkHsWrap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[PredType] -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpTyApps"><span class="hs-identifier hs-var">mkWpTyApps</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681163043"><span class="hs-identifier hs-var">inst_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1156"></span><span>                                  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XConLikeOut GhcTc -&gt; ConLike -&gt; HsExpr GhcTc
forall p. XConLikeOut p -&gt; ConLike -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsConLikeOut"><span class="hs-identifier hs-var">HsConLikeOut</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XConLikeOut GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; ConLike
</span><a href="GHC.Core.ConLike.html#RealDataCon"><span class="hs-identifier hs-var">RealDataCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681162999"><span class="hs-identifier hs-var">dict_constr</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1157"></span><span>                       </span><span class="hs-comment">-- NB: We *can* have covars in inst_tys, in the case of</span><span>
</span><span id="line-1158"></span><span>                       </span><span class="hs-comment">-- promoted GADT constructors.</span><span>
</span><span id="line-1159"></span><span>
</span><span id="line-1160"></span><span>             </span><span id="local-6989586621681162995"><span class="annot"><span class="annottext">con_app_args :: HsExpr GhcTc
</span><a href="#local-6989586621681162995"><span class="hs-identifier hs-var hs-var">con_app_args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(HsExpr GhcTc -&gt; Id -&gt; HsExpr GhcTc)
-&gt; HsExpr GhcTc -&gt; [Id] -&gt; HsExpr GhcTc
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc -&gt; Id -&gt; HsExpr GhcTc
</span><a href="#local-6989586621681162987"><span class="hs-identifier hs-var">app_to_meth</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681162994"><span class="hs-identifier hs-var">con_app_tys</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163026"><span class="hs-identifier hs-var">sc_meth_ids</span></a></span><span>
</span><span id="line-1161"></span><span>
</span><span id="line-1162"></span><span>             </span><span class="annot"><a href="#local-6989586621681162987"><span class="hs-identifier hs-type">app_to_meth</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span>
</span><span id="line-1163"></span><span>             </span><span id="local-6989586621681162987"><span class="annot"><span class="annottext">app_to_meth :: HsExpr GhcTc -&gt; Id -&gt; HsExpr GhcTc
</span><a href="#local-6989586621681162987"><span class="hs-identifier hs-var hs-var">app_to_meth</span></a></span></span><span> </span><span id="local-6989586621681162986"><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681162986"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621681162985"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162985"><span class="hs-identifier hs-var">meth_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">XApp GhcTc -&gt; LHsExpr GhcTc -&gt; LHsExpr GhcTc -&gt; HsExpr GhcTc
forall p. XApp p -&gt; LHsExpr p -&gt; LHsExpr p -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsApp"><span class="hs-identifier hs-var">HsApp</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XApp GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; HsExpr GhcTc -&gt; LHsExpr GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163054"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">HsExpr GhcTc
</span><a href="#local-6989586621681162986"><span class="hs-identifier hs-var">fun</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1164"></span><span>                                            </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; HsExpr GhcTc -&gt; LHsExpr GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163054"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HsWrapper -&gt; Id -&gt; HsExpr GhcTc
</span><a href="GHC.Tc.TyCl.Instance.html#wrapId"><span class="hs-identifier hs-var">wrapId</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162982"><span class="hs-identifier hs-var">arg_wrapper</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162985"><span class="hs-identifier hs-var">meth_id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1165"></span><span>
</span><span id="line-1166"></span><span>             </span><span id="local-6989586621681162981"><span class="annot"><span class="annottext">inst_tv_tys :: [PredType]
</span><a href="#local-6989586621681162981"><span class="hs-identifier hs-var hs-var">inst_tv_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [PredType]
</span><a href="GHC.Core.TyCo.Rep.html#mkTyVarTys"><span class="hs-identifier hs-var">mkTyVarTys</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163050"><span class="hs-identifier hs-var">inst_tyvars</span></a></span><span>
</span><span id="line-1167"></span><span>             </span><span id="local-6989586621681162982"><span class="annot"><span class="annottext">arg_wrapper :: HsWrapper
</span><a href="#local-6989586621681162982"><span class="hs-identifier hs-var hs-var">arg_wrapper</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpEvVarApps"><span class="hs-identifier hs-var">mkWpEvVarApps</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163046"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpTyApps"><span class="hs-identifier hs-var">mkWpTyApps</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162981"><span class="hs-identifier hs-var">inst_tv_tys</span></a></span><span>
</span><span id="line-1168"></span><span>
</span><span id="line-1169"></span><span>             </span><span id="local-6989586621681162978"><span class="annot"><span class="annottext">is_newtype :: Bool
</span><a href="#local-6989586621681162978"><span class="hs-identifier hs-var hs-var">is_newtype</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isNewTyCon"><span class="hs-identifier hs-var">isNewTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681163001"><span class="hs-identifier hs-var">class_tc</span></a></span><span>
</span><span id="line-1170"></span><span>             </span><span id="local-6989586621681162976"><span class="annot"><span class="annottext">dfun_id_w_prags :: Id
</span><a href="#local-6989586621681162976"><span class="hs-identifier hs-var hs-var">dfun_id_w_prags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Id] -&gt; Id
</span><a href="GHC.Tc.TyCl.Instance.html#addDFunPrags"><span class="hs-identifier hs-var">addDFunPrags</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163051"><span class="hs-identifier hs-var">dfun_id</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163026"><span class="hs-identifier hs-var">sc_meth_ids</span></a></span><span>
</span><span id="line-1171"></span><span>             </span><span id="local-6989586621681162974"><span class="annot"><span class="annottext">dfun_spec_prags :: TcSpecPrags
</span><a href="#local-6989586621681162974"><span class="hs-identifier hs-var hs-var">dfun_spec_prags</span></a></span></span><span>
</span><span id="line-1172"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162978"><span class="hs-identifier hs-var">is_newtype</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Located TcSpecPrag] -&gt; TcSpecPrags
</span><a href="GHC.Hs.Binds.html#SpecPrags"><span class="hs-identifier hs-var">SpecPrags</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1173"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Located TcSpecPrag] -&gt; TcSpecPrags
</span><a href="GHC.Hs.Binds.html#SpecPrags"><span class="hs-identifier hs-var">SpecPrags</span></a></span><span> </span><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681163033"><span class="hs-identifier hs-var">spec_inst_prags</span></a></span><span>
</span><span id="line-1174"></span><span>                    </span><span class="hs-comment">-- Newtype dfuns just inline unconditionally,</span><span>
</span><span id="line-1175"></span><span>                    </span><span class="hs-comment">-- so don't attempt to specialise them</span><span>
</span><span id="line-1176"></span><span>
</span><span id="line-1177"></span><span>             </span><span id="local-6989586621681162972"><span class="annot"><span class="annottext">export :: ABExport GhcTc
</span><a href="#local-6989586621681162972"><span class="hs-keyword hs-var hs-var">export</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ABE :: forall p.
XABE p -&gt; IdP p -&gt; IdP p -&gt; HsWrapper -&gt; TcSpecPrags -&gt; ABExport p
</span><a href="GHC.Hs.Binds.html#ABE"><span class="hs-identifier hs-type">ABE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">abe_ext :: XABE GhcTc
</span><a href="GHC.Hs.Binds.html#abe_ext"><span class="hs-identifier hs-var">abe_ext</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NoExtField
XABE GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span>
</span><span id="line-1178"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_wrap :: HsWrapper
</span><a href="GHC.Hs.Binds.html#abe_wrap"><span class="hs-identifier hs-var">abe_wrap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span>
</span><span id="line-1179"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_poly :: IdP GhcTc
</span><a href="GHC.Hs.Binds.html#abe_poly"><span class="hs-identifier hs-var">abe_poly</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681162976"><span class="hs-identifier hs-var">dfun_id_w_prags</span></a></span><span>
</span><span id="line-1180"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_mono :: IdP GhcTc
</span><a href="GHC.Hs.Binds.html#abe_mono"><span class="hs-identifier hs-var">abe_mono</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681163003"><span class="hs-identifier hs-var">self_dict</span></a></span><span>
</span><span id="line-1181"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_prags :: TcSpecPrags
</span><a href="GHC.Hs.Binds.html#abe_prags"><span class="hs-identifier hs-var">abe_prags</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcSpecPrags
</span><a href="#local-6989586621681162974"><span class="hs-identifier hs-var">dfun_spec_prags</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1182"></span><span>                          </span><span class="hs-comment">-- NB: see Note [SPECIALISE instance pragmas]</span><span>
</span><span id="line-1183"></span><span>             </span><span id="local-6989586621681162964"><span class="annot"><span class="annottext">main_bind :: HsBindLR GhcTc GhcTc
</span><a href="#local-6989586621681162964"><span class="hs-identifier hs-var hs-var">main_bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsBinds :: forall idL idR.
XAbsBinds idL idR
-&gt; [Id]
-&gt; [Id]
-&gt; [ABExport idL]
-&gt; [TcEvBinds]
-&gt; LHsBinds idL
-&gt; Bool
-&gt; HsBindLR idL idR
</span><a href="GHC.Hs.Binds.html#AbsBinds"><span class="hs-identifier hs-type">AbsBinds</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">abs_ext :: XAbsBinds GhcTc GhcTc
</span><a href="GHC.Hs.Binds.html#abs_ext"><span class="hs-identifier hs-var">abs_ext</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NoExtField
XAbsBinds GhcTc GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span>
</span><span id="line-1184"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_tvs :: [Id]
</span><a href="GHC.Hs.Binds.html#abs_tvs"><span class="hs-identifier hs-var">abs_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163050"><span class="hs-identifier hs-var">inst_tyvars</span></a></span><span>
</span><span id="line-1185"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_ev_vars :: [Id]
</span><a href="GHC.Hs.Binds.html#abs_ev_vars"><span class="hs-identifier hs-var">abs_ev_vars</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681163046"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span>
</span><span id="line-1186"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_exports :: [ABExport GhcTc]
</span><a href="GHC.Hs.Binds.html#abs_exports"><span class="hs-identifier hs-var">abs_exports</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">ABExport GhcTc
</span><a href="#local-6989586621681162972"><span class="hs-keyword hs-var">export</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1187"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_ev_binds :: [TcEvBinds]
</span><a href="GHC.Hs.Binds.html#abs_ev_binds"><span class="hs-identifier hs-var">abs_ev_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1188"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_binds :: LHsBinds GhcTc
</span><a href="GHC.Hs.Binds.html#abs_binds"><span class="hs-identifier hs-var">abs_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LHsBind GhcTc -&gt; LHsBinds GhcTc
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBind GhcTc
</span><a href="#local-6989586621681162997"><span class="hs-identifier hs-var">dict_bind</span></a></span><span>
</span><span id="line-1189"></span><span>                                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_sig :: Bool
</span><a href="GHC.Hs.Binds.html#abs_sig"><span class="hs-identifier hs-var">abs_sig</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1190"></span><span>
</span><span id="line-1191"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc -&gt; TcM (LHsBinds GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsBind GhcTc -&gt; LHsBinds GhcTc
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan -&gt; HsBindLR GhcTc GhcTc -&gt; LHsBind GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681163054"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">HsBindLR GhcTc GhcTc
</span><a href="#local-6989586621681162964"><span class="hs-identifier hs-var">main_bind</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc -&gt; LHsBinds GhcTc -&gt; LHsBinds GhcTc
forall a. Bag a -&gt; Bag a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unionBags"><span class="hs-operator hs-var">`unionBags`</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681163025"><span class="hs-identifier hs-var">sc_meth_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1192"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-1193"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1194"></span><span>   </span><span id="local-6989586621681163051"><span class="annot"><span class="annottext">dfun_id :: Id
</span><a href="#local-6989586621681163051"><span class="hs-identifier hs-var hs-var">dfun_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ClsInst -&gt; Id
</span><a href="GHC.Core.InstEnv.html#instanceDFunId"><span class="hs-identifier hs-var">instanceDFunId</span></a></span><span> </span><span class="annot"><span class="annottext">ClsInst
</span><a href="#local-6989586621681163058"><span class="hs-identifier hs-var">ispec</span></a></span><span>
</span><span id="line-1195"></span><span>   </span><span id="local-6989586621681163054"><span class="annot"><span class="annottext">loc :: SrcSpan
</span><a href="#local-6989586621681163054"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681163051"><span class="hs-identifier hs-var">dfun_id</span></a></span><span>
</span><span id="line-1196"></span><span>
</span><span id="line-1197"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#addDFunPrags"><span class="hs-identifier hs-type">addDFunPrags</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#DFunId"><span class="hs-identifier hs-type">DFunId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#DFunId"><span class="hs-identifier hs-type">DFunId</span></a></span><span>
</span><span id="line-1198"></span><span class="hs-comment">-- DFuns need a special Unfolding and InlinePrag</span><span>
</span><span id="line-1199"></span><span class="hs-comment">--    See Note [ClassOp/DFun selection]</span><span>
</span><span id="line-1200"></span><span class="hs-comment">--    and Note [Single-method classes]</span><span>
</span><span id="line-1201"></span><span class="hs-comment">-- It's easiest to create those unfoldings right here, where</span><span>
</span><span id="line-1202"></span><span class="hs-comment">-- have all the pieces in hand, even though we are messing with</span><span>
</span><span id="line-1203"></span><span class="hs-comment">-- Core at this point, which the typechecker doesn't usually do</span><span>
</span><span id="line-1204"></span><span class="hs-comment">-- However we take care to build the unfolding using the TyVars from</span><span>
</span><span id="line-1205"></span><span class="hs-comment">-- the DFunId rather than from the skolem pieces that the typechecker</span><span>
</span><span id="line-1206"></span><span class="hs-comment">-- is messing with.</span><span>
</span><span id="line-1207"></span><span id="addDFunPrags"><span class="annot"><span class="annottext">addDFunPrags :: Id -&gt; [Id] -&gt; Id
</span><a href="GHC.Tc.TyCl.Instance.html#addDFunPrags"><span class="hs-identifier hs-var hs-var">addDFunPrags</span></a></span></span><span> </span><span id="local-6989586621681162951"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162951"><span class="hs-identifier hs-var">dfun_id</span></a></span></span><span> </span><span id="local-6989586621681162950"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162950"><span class="hs-identifier hs-var">sc_meth_ids</span></a></span></span><span>
</span><span id="line-1208"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162949"><span class="hs-identifier hs-var">is_newtype</span></a></span><span>
</span><span id="line-1209"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162951"><span class="hs-identifier hs-var">dfun_id</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Unfolding -&gt; Id
</span><a href="GHC.Types.Id.html#setIdUnfolding"><span class="hs-operator hs-var">`setIdUnfolding`</span></a></span><span>  </span><span class="annot"><span class="annottext">ConTag -&gt; CoreExpr -&gt; Unfolding
</span><a href="GHC.Core.Unfold.html#mkInlineUnfoldingWithArity"><span class="hs-identifier hs-var">mkInlineUnfoldingWithArity</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">CoreExpr
</span><a href="#local-6989586621681162947"><span class="hs-identifier hs-var">con_app</span></a></span><span>
</span><span id="line-1210"></span><span>            </span><span class="annot"><span class="annottext">Id -&gt; InlinePragma -&gt; Id
</span><a href="GHC.Types.Id.html#setInlinePragma"><span class="hs-operator hs-var">`setInlinePragma`</span></a></span><span> </span><span class="annot"><span class="annottext">InlinePragma
</span><a href="GHC.Types.Basic.html#alwaysInlinePragma"><span class="hs-identifier hs-var">alwaysInlinePragma</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">inl_sat :: Maybe ConTag
</span><a href="GHC.Types.Basic.html#inl_sat"><span class="hs-identifier hs-var">inl_sat</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConTag -&gt; Maybe ConTag
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">0</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1211"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1212"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162951"><span class="hs-identifier hs-var">dfun_id</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; Unfolding -&gt; Id
</span><a href="GHC.Types.Id.html#setIdUnfolding"><span class="hs-operator hs-var">`setIdUnfolding`</span></a></span><span>  </span><span class="annot"><span class="annottext">[Id] -&gt; DataCon -&gt; [CoreExpr] -&gt; Unfolding
</span><a href="GHC.Core.Unfold.html#mkDFunUnfolding"><span class="hs-identifier hs-var">mkDFunUnfolding</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162943"><span class="hs-identifier hs-var">dfun_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681162942"><span class="hs-identifier hs-var">dict_con</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681162941"><span class="hs-identifier hs-var">dict_args</span></a></span><span>
</span><span id="line-1213"></span><span>           </span><span class="annot"><span class="annottext">Id -&gt; InlinePragma -&gt; Id
</span><a href="GHC.Types.Id.html#setInlinePragma"><span class="hs-operator hs-var">`setInlinePragma`</span></a></span><span> </span><span class="annot"><span class="annottext">InlinePragma
</span><a href="GHC.Types.Basic.html#dfunInlinePragma"><span class="hs-identifier hs-var">dfunInlinePragma</span></a></span><span>
</span><span id="line-1214"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-1215"></span><span>   </span><span id="local-6989586621681162947"><span class="annot"><span class="annottext">con_app :: CoreExpr
</span><a href="#local-6989586621681162947"><span class="hs-identifier hs-var hs-var">con_app</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; CoreExpr -&gt; CoreExpr
forall b. [b] -&gt; Expr b -&gt; Expr b
</span><a href="GHC.Core.html#mkLams"><span class="hs-identifier hs-var">mkLams</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162943"><span class="hs-identifier hs-var">dfun_bndrs</span></a></span><span> </span><span class="annot"><span class="annottext">(CoreExpr -&gt; CoreExpr) -&gt; CoreExpr -&gt; CoreExpr
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1216"></span><span>                </span><span class="annot"><span class="annottext">CoreExpr -&gt; [CoreExpr] -&gt; CoreExpr
forall b. Expr b -&gt; [Expr b] -&gt; Expr b
</span><a href="GHC.Core.html#mkApps"><span class="hs-identifier hs-var">mkApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; Id
</span><a href="GHC.Core.DataCon.html#dataConWrapId"><span class="hs-identifier hs-var">dataConWrapId</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681162942"><span class="hs-identifier hs-var">dict_con</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[CoreExpr]
</span><a href="#local-6989586621681162941"><span class="hs-identifier hs-var">dict_args</span></a></span><span>
</span><span id="line-1217"></span><span>                 </span><span class="hs-comment">-- mkApps is OK because of the checkForLevPoly call in checkValidClass</span><span>
</span><span id="line-1218"></span><span>                 </span><span class="hs-comment">-- See Note [Levity polymorphism checking] in GHC.HsToCore.Monad</span><span>
</span><span id="line-1219"></span><span>   </span><span id="local-6989586621681162941"><span class="annot"><span class="annottext">dict_args :: [CoreExpr]
</span><a href="#local-6989586621681162941"><span class="hs-identifier hs-var hs-var">dict_args</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(PredType -&gt; CoreExpr) -&gt; [PredType] -&gt; [CoreExpr]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; CoreExpr
forall b. PredType -&gt; Expr b
</span><a href="GHC.Core.html#Type"><span class="hs-identifier hs-var">Type</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162936"><span class="hs-identifier hs-var">inst_tys</span></a></span><span> </span><span class="annot"><span class="annottext">[CoreExpr] -&gt; [CoreExpr] -&gt; [CoreExpr]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span>
</span><span id="line-1220"></span><span>                </span><span class="hs-special">[</span><span class="annot"><span class="annottext">CoreExpr -&gt; [Id] -&gt; CoreExpr
forall b. Expr b -&gt; [Id] -&gt; Expr b
</span><a href="GHC.Core.html#mkVarApps"><span class="hs-identifier hs-var">mkVarApps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; CoreExpr
forall b. Id -&gt; Expr b
</span><a href="GHC.Core.html#Var"><span class="hs-identifier hs-var">Var</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162935"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162943"><span class="hs-identifier hs-var">dfun_bndrs</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681162935"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162935"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162950"><span class="hs-identifier hs-var">sc_meth_ids</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1221"></span><span>
</span><span id="line-1222"></span><span>   </span><span class="hs-special">(</span><span id="local-6989586621681162934"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162934"><span class="hs-identifier hs-var">dfun_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162933"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162933"><span class="hs-identifier hs-var">dfun_theta</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162932"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162932"><span class="hs-identifier hs-var">clas</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162936"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162936"><span class="hs-identifier hs-var">inst_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; ([Id], [PredType], Class, [PredType])
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitDFunTy"><span class="hs-identifier hs-var">tcSplitDFunTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162951"><span class="hs-identifier hs-var">dfun_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1223"></span><span>   </span><span id="local-6989586621681162931"><span class="annot"><span class="annottext">ev_ids :: [Id]
</span><a href="#local-6989586621681162931"><span class="hs-identifier hs-var hs-var">ev_ids</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ConTag -&gt; [PredType] -&gt; [Id]
</span><a href="GHC.Types.Id.html#mkTemplateLocalsNum"><span class="hs-identifier hs-var">mkTemplateLocalsNum</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">1</span></span><span>                    </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162933"><span class="hs-identifier hs-var">dfun_theta</span></a></span><span>
</span><span id="line-1224"></span><span>   </span><span id="local-6989586621681162943"><span class="annot"><span class="annottext">dfun_bndrs :: [Id]
</span><a href="#local-6989586621681162943"><span class="hs-identifier hs-var hs-var">dfun_bndrs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162934"><span class="hs-identifier hs-var">dfun_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [Id] -&gt; [Id]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162931"><span class="hs-identifier hs-var">ev_ids</span></a></span><span>
</span><span id="line-1225"></span><span>   </span><span id="local-6989586621681162929"><span class="annot"><span class="annottext">clas_tc :: TyCon
</span><a href="#local-6989586621681162929"><span class="hs-identifier hs-var hs-var">clas_tc</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; TyCon
</span><a href="GHC.Core.Class.html#classTyCon"><span class="hs-identifier hs-var hs-var">classTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162932"><span class="hs-identifier hs-var">clas</span></a></span><span>
</span><span id="line-1226"></span><span>   </span><span class="hs-special">[</span><span id="local-6989586621681162942"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681162942"><span class="hs-identifier hs-var">dict_con</span></a></span></span><span class="hs-special">]</span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons"><span class="hs-identifier hs-var">tyConDataCons</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681162929"><span class="hs-identifier hs-var">clas_tc</span></a></span><span>
</span><span id="line-1227"></span><span>   </span><span id="local-6989586621681162949"><span class="annot"><span class="annottext">is_newtype :: Bool
</span><a href="#local-6989586621681162949"><span class="hs-identifier hs-var hs-var">is_newtype</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isNewTyCon"><span class="hs-identifier hs-var">isNewTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681162929"><span class="hs-identifier hs-var">clas_tc</span></a></span><span>
</span><span id="line-1228"></span><span>
</span><span id="line-1229"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#wrapId"><span class="hs-identifier hs-type">wrapId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#HsWrapper"><span class="hs-identifier hs-type">HsWrapper</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#HsExpr"><span class="hs-identifier hs-type">HsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span>
</span><span id="line-1230"></span><span id="wrapId"><span class="annot"><span class="annottext">wrapId :: HsWrapper -&gt; Id -&gt; HsExpr GhcTc
</span><a href="GHC.Tc.TyCl.Instance.html#wrapId"><span class="hs-identifier hs-var hs-var">wrapId</span></a></span></span><span> </span><span id="local-6989586621681162928"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162928"><span class="hs-identifier hs-var">wrapper</span></a></span></span><span> </span><span id="local-6989586621681162927"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162927"><span class="hs-identifier hs-var">id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsExpr GhcTc -&gt; HsExpr GhcTc
</span><a href="GHC.Hs.Utils.html#mkHsWrap"><span class="hs-identifier hs-var">mkHsWrap</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162928"><span class="hs-identifier hs-var">wrapper</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XVar GhcTc -&gt; Located (IdP GhcTc) -&gt; HsExpr GhcTc
forall p. XVar p -&gt; Located (IdP p) -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsVar"><span class="hs-identifier hs-var">HsVar</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XVar GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Located Id
forall e. e -&gt; Located e
</span><a href="GHC.Types.SrcLoc.html#noLoc"><span class="hs-identifier hs-var">noLoc</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162927"><span class="hs-identifier hs-var">id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1231"></span><span>
</span><span id="line-1232"></span><span class="hs-comment">{- Note [Typechecking plan for instance declarations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For instance declarations we generate the following bindings and implication
constraints.  Example:

   instance Ord a =&gt; Ord [a] where compare = &lt;compare-rhs&gt;

generates this:

   Bindings:
      -- Method bindings
      $ccompare :: forall a. Ord a =&gt; a -&gt; a -&gt; Ordering
      $ccompare = /\a \(d:Ord a). let &lt;meth-ev-binds&gt; in ...

      -- Superclass bindings
      $cp1Ord :: forall a. Ord a =&gt; Eq [a]
      $cp1Ord = /\a \(d:Ord a). let &lt;sc-ev-binds&gt;
               in dfEqList (dw :: Eq a)

   Constraints:
      forall a. Ord a =&gt;
                -- Method constraint
             (forall. (empty) =&gt; &lt;constraints from compare-rhs&gt;)
                -- Superclass constraint
          /\ (forall. (empty) =&gt; dw :: Eq a)

Notice that

 * Per-meth/sc implication.  There is one inner implication per
   superclass or method, with no skolem variables or givens.  The only
   reason for this one is to gather the evidence bindings privately
   for this superclass or method.  This implication is generated
   by checkInstConstraints.

 * Overall instance implication. There is an overall enclosing
   implication for the whole instance declaration, with the expected
   skolems and givens.  We need this to get the correct &quot;redundant
   constraint&quot; warnings, gathering all the uses from all the methods
   and superclasses.  See GHC.Tc.Solver Note [Tracking redundant
   constraints]

 * The given constraints in the outer implication may generate
   evidence, notably by superclass selection.  Since the method and
   superclass bindings are top-level, we want that evidence copied
   into *every* method or superclass definition.  (Some of it will
   be usused in some, but dead-code elimination will drop it.)

   We achieve this by putting the evidence variable for the overall
   instance implication into the AbsBinds for each method/superclass.
   Hence the 'dfun_ev_binds' passed into tcMethods and tcSuperClasses.
   (And that in turn is why the abs_ev_binds field of AbBinds is a
   [TcEvBinds] rather than simply TcEvBinds.

   This is a bit of a hack, but works very nicely in practice.

 * Note that if a method has a locally-polymorphic binding, there will
   be yet another implication for that, generated by tcPolyCheck
   in tcMethodBody. E.g.
          class C a where
            foo :: forall b. Ord b =&gt; blah


************************************************************************
*                                                                      *
      Type-checking superclasses
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-1300"></span><span>
</span><span id="line-1301"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcSuperClasses"><span class="hs-identifier hs-type">tcSuperClasses</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#DFunId"><span class="hs-identifier hs-type">DFunId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1302"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcEvBinds"><span class="hs-identifier hs-type">TcEvBinds</span></a></span><span>
</span><span id="line-1303"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcThetaType"><span class="hs-identifier hs-type">TcThetaType</span></a></span><span>
</span><span id="line-1304"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1305"></span><span class="hs-comment">-- Make a new top-level function binding for each superclass,</span><span>
</span><span id="line-1306"></span><span class="hs-comment">-- something like</span><span>
</span><span id="line-1307"></span><span class="hs-comment">--    $Ordp1 :: forall a. Ord a =&gt; Eq [a]</span><span>
</span><span id="line-1308"></span><span class="hs-comment">--    $Ordp1 = /\a \(d:Ord a). dfunEqList a (sc_sel d)</span><span>
</span><span id="line-1309"></span><span class="hs-comment">--</span><span>
</span><span id="line-1310"></span><span class="hs-comment">-- See Note [Recursive superclasses] for why this is so hard!</span><span>
</span><span id="line-1311"></span><span class="hs-comment">-- In effect, we build a special-purpose solver for the first step</span><span>
</span><span id="line-1312"></span><span class="hs-comment">-- of solving each superclass constraint</span><span>
</span><span id="line-1313"></span><span id="tcSuperClasses"><span class="annot"><span class="annottext">tcSuperClasses :: Id
-&gt; Class
-&gt; [Id]
-&gt; [Id]
-&gt; [PredType]
-&gt; TcEvBinds
-&gt; [PredType]
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
</span><a href="GHC.Tc.TyCl.Instance.html#tcSuperClasses"><span class="hs-identifier hs-var hs-var">tcSuperClasses</span></a></span></span><span> </span><span id="local-6989586621681162920"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162920"><span class="hs-identifier hs-var">dfun_id</span></a></span></span><span> </span><span id="local-6989586621681162919"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162919"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681162918"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162918"><span class="hs-identifier hs-var">tyvars</span></a></span></span><span> </span><span id="local-6989586621681162917"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162917"><span class="hs-identifier hs-var">dfun_evs</span></a></span></span><span> </span><span id="local-6989586621681162916"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162916"><span class="hs-identifier hs-var">inst_tys</span></a></span></span><span> </span><span id="local-6989586621681162915"><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681162915"><span class="hs-identifier hs-var">dfun_ev_binds</span></a></span></span><span> </span><span id="local-6989586621681162914"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162914"><span class="hs-identifier hs-var">sc_theta</span></a></span></span><span>
</span><span id="line-1314"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162913"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162913"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162912"><span class="annot"><span class="annottext">[LHsBind GhcTc]
</span><a href="#local-6989586621681162912"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162911"><span class="annot"><span class="annottext">[Implication]
</span><a href="#local-6989586621681162911"><span class="hs-identifier hs-var">implics</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">((PredType, ConTag)
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Implication))
-&gt; [(PredType, ConTag)]
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) ([Id], [LHsBind GhcTc], [Implication])
forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; m (b, c, d)) -&gt; [a] -&gt; m ([b], [c], [d])
</span><a href="GHC.Utils.Monad.html#mapAndUnzip3M"><span class="hs-identifier hs-var">mapAndUnzip3M</span></a></span><span> </span><span class="annot"><span class="annottext">(PredType, ConTag)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Implication)
</span><a href="#local-6989586621681162909"><span class="hs-identifier hs-var">tc_super</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[PredType] -&gt; [ConTag] -&gt; [(PredType, ConTag)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162914"><span class="hs-identifier hs-var">sc_theta</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">ConTag
</span><a href="GHC.Types.Basic.html#fIRST_TAG"><span class="hs-identifier hs-var">fIRST_TAG</span></a></span><span class="hs-glyph">..</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1315"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([Id], LHsBinds GhcTc, Bag Implication)
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162913"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[LHsBind GhcTc] -&gt; LHsBinds GhcTc
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[LHsBind GhcTc]
</span><a href="#local-6989586621681162912"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Implication] -&gt; Bag Implication
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[Implication]
</span><a href="#local-6989586621681162911"><span class="hs-identifier hs-var">implics</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1316"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1317"></span><span>    </span><span id="local-6989586621681162906"><span class="annot"><span class="annottext">loc :: SrcSpan
</span><a href="#local-6989586621681162906"><span class="hs-identifier hs-var hs-var">loc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162920"><span class="hs-identifier hs-var">dfun_id</span></a></span><span>
</span><span id="line-1318"></span><span>    </span><span id="local-6989586621681162905"><span class="annot"><span class="annottext">size :: TypeSize
</span><a href="#local-6989586621681162905"><span class="hs-identifier hs-var hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; TypeSize
</span><a href="GHC.Tc.Utils.TcType.html#sizeTypes"><span class="hs-identifier hs-var">sizeTypes</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162916"><span class="hs-identifier hs-var">inst_tys</span></a></span><span>
</span><span id="line-1319"></span><span>    </span><span id="local-6989586621681162909"><span class="annot"><span class="annottext">tc_super :: (PredType, ConTag)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Implication)
</span><a href="#local-6989586621681162909"><span class="hs-identifier hs-var hs-var">tc_super</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162903"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162903"><span class="hs-identifier hs-var">sc_pred</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162902"><span class="annot"><span class="annottext">ConTag
</span><a href="#local-6989586621681162902"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1320"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162901"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681162901"><span class="hs-identifier hs-var">sc_implic</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162900"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681162900"><span class="hs-identifier hs-var">ev_binds_var</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162899"><span class="annot"><span class="annottext">EvTerm
</span><a href="#local-6989586621681162899"><span class="hs-identifier hs-var">sc_ev_tm</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1321"></span><span>                </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM EvTerm -&gt; TcM (Implication, EvBindsVar, EvTerm)
forall result. TcM result -&gt; TcM (Implication, EvBindsVar, result)
</span><a href="GHC.Tc.TyCl.Instance.html#checkInstConstraints"><span class="hs-identifier hs-var">checkInstConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM EvTerm -&gt; TcM (Implication, EvBindsVar, EvTerm))
-&gt; TcM EvTerm -&gt; TcM (Implication, EvBindsVar, EvTerm)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin -&gt; PredType -&gt; TcM EvTerm
</span><a href="GHC.Tc.Utils.TcMType.html#emitWanted"><span class="hs-identifier hs-var">emitWanted</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TypeSize -&gt; CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#ScOrigin"><span class="hs-identifier hs-var">ScOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">TypeSize
</span><a href="#local-6989586621681162905"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162903"><span class="hs-identifier hs-var">sc_pred</span></a></span><span>
</span><span id="line-1322"></span><span>
</span><span id="line-1323"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162895"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162895"><span class="hs-identifier hs-var">sc_top_name</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Monad.html#newName"><span class="hs-identifier hs-var">newName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ConTag -&gt; OccName -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkSuperDictAuxOcc"><span class="hs-identifier hs-var">mkSuperDictAuxOcc</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag
</span><a href="#local-6989586621681162902"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; OccName
forall a. NamedThing a =&gt; a -&gt; OccName
</span><a href="GHC.Types.Name.html#getOccName"><span class="hs-identifier hs-var">getOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162919"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1324"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162891"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162891"><span class="hs-identifier hs-var">sc_ev_id</span></a></span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; TcM Id
forall gbl lcl. PredType -&gt; TcRnIf gbl lcl Id
</span><a href="GHC.Tc.Utils.TcMType.html#newEvVar"><span class="hs-identifier hs-var">newEvVar</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162903"><span class="hs-identifier hs-var">sc_pred</span></a></span><span>
</span><span id="line-1325"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; EvBind -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#addTcEvBind"><span class="hs-identifier hs-var">addTcEvBind</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681162900"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span> </span><span class="annot"><span class="annottext">(EvBind -&gt; TcRn ()) -&gt; EvBind -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; EvTerm -&gt; EvBind
</span><a href="GHC.Tc.Types.Evidence.html#mkWantedEvBind"><span class="hs-identifier hs-var">mkWantedEvBind</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162891"><span class="hs-identifier hs-var">sc_ev_id</span></a></span><span> </span><span class="annot"><span class="annottext">EvTerm
</span><a href="#local-6989586621681162899"><span class="hs-identifier hs-var">sc_ev_tm</span></a></span><span>
</span><span id="line-1326"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162887"><span class="annot"><span class="annottext">sc_top_ty :: PredType
</span><a href="#local-6989586621681162887"><span class="hs-identifier hs-var hs-var">sc_top_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; PredType -&gt; PredType
</span><a href="GHC.Core.Type.html#mkInfForAllTys"><span class="hs-identifier hs-var">mkInfForAllTys</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162918"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">(PredType -&gt; PredType) -&gt; PredType -&gt; PredType
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1327"></span><span>                             </span><span class="annot"><span class="annottext">[PredType] -&gt; PredType -&gt; PredType
</span><a href="GHC.Tc.Utils.TcType.html#mkPhiTy"><span class="hs-identifier hs-var">mkPhiTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Id -&gt; PredType) -&gt; [Id] -&gt; [PredType]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162917"><span class="hs-identifier hs-var">dfun_evs</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162903"><span class="hs-identifier hs-var">sc_pred</span></a></span><span>
</span><span id="line-1328"></span><span>                 </span><span id="local-6989586621681162884"><span class="annot"><span class="annottext">sc_top_id :: Id
</span><a href="#local-6989586621681162884"><span class="hs-identifier hs-var hs-var">sc_top_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Name -&gt; PredType -&gt; PredType -&gt; Id
Name -&gt; PredType -&gt; PredType -&gt; Id
</span><a href="GHC.Types.Id.html#mkLocalId"><span class="hs-identifier hs-var">mkLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162895"><span class="hs-identifier hs-var">sc_top_name</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162887"><span class="hs-identifier hs-var">sc_top_ty</span></a></span><span>
</span><span id="line-1329"></span><span>                 </span><span id="local-6989586621681162881"><span class="annot"><span class="annottext">export :: ABExport GhcTc
</span><a href="#local-6989586621681162881"><span class="hs-keyword hs-var hs-var">export</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ABE :: forall p.
XABE p -&gt; IdP p -&gt; IdP p -&gt; HsWrapper -&gt; TcSpecPrags -&gt; ABExport p
</span><a href="GHC.Hs.Binds.html#ABE"><span class="hs-identifier hs-type">ABE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">abe_ext :: XABE GhcTc
</span><a href="GHC.Hs.Binds.html#abe_ext"><span class="hs-identifier hs-var">abe_ext</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NoExtField
XABE GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span>
</span><span id="line-1330"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_wrap :: HsWrapper
</span><a href="GHC.Hs.Binds.html#abe_wrap"><span class="hs-identifier hs-var">abe_wrap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span>
</span><span id="line-1331"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_poly :: IdP GhcTc
</span><a href="GHC.Hs.Binds.html#abe_poly"><span class="hs-identifier hs-var">abe_poly</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681162884"><span class="hs-identifier hs-var">sc_top_id</span></a></span><span>
</span><span id="line-1332"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_mono :: IdP GhcTc
</span><a href="GHC.Hs.Binds.html#abe_mono"><span class="hs-identifier hs-var">abe_mono</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681162891"><span class="hs-identifier hs-var">sc_ev_id</span></a></span><span>
</span><span id="line-1333"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_prags :: TcSpecPrags
</span><a href="GHC.Hs.Binds.html#abe_prags"><span class="hs-identifier hs-var">abe_prags</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcSpecPrags
</span><a href="GHC.Hs.Binds.html#noSpecPrags"><span class="hs-identifier hs-var">noSpecPrags</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1334"></span><span>                 </span><span id="local-6989586621681162879"><span class="annot"><span class="annottext">local_ev_binds :: TcEvBinds
</span><a href="#local-6989586621681162879"><span class="hs-identifier hs-var hs-var">local_ev_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcEvBinds
</span><a href="GHC.Tc.Types.Evidence.html#TcEvBinds"><span class="hs-identifier hs-var">TcEvBinds</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681162900"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-1335"></span><span>                 </span><span id="local-6989586621681162878"><span class="annot"><span class="annottext">bind :: HsBindLR GhcTc GhcTc
</span><a href="#local-6989586621681162878"><span class="hs-identifier hs-var hs-var">bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsBinds :: forall idL idR.
XAbsBinds idL idR
-&gt; [Id]
-&gt; [Id]
-&gt; [ABExport idL]
-&gt; [TcEvBinds]
-&gt; LHsBinds idL
-&gt; Bool
-&gt; HsBindLR idL idR
</span><a href="GHC.Hs.Binds.html#AbsBinds"><span class="hs-identifier hs-type">AbsBinds</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">abs_ext :: XAbsBinds GhcTc GhcTc
</span><a href="GHC.Hs.Binds.html#abs_ext"><span class="hs-identifier hs-var">abs_ext</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NoExtField
XAbsBinds GhcTc GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span>
</span><span id="line-1336"></span><span>                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_tvs :: [Id]
</span><a href="GHC.Hs.Binds.html#abs_tvs"><span class="hs-identifier hs-var">abs_tvs</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162918"><span class="hs-identifier hs-var">tyvars</span></a></span><span>
</span><span id="line-1337"></span><span>                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_ev_vars :: [Id]
</span><a href="GHC.Hs.Binds.html#abs_ev_vars"><span class="hs-identifier hs-var">abs_ev_vars</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162917"><span class="hs-identifier hs-var">dfun_evs</span></a></span><span>
</span><span id="line-1338"></span><span>                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_exports :: [ABExport GhcTc]
</span><a href="GHC.Hs.Binds.html#abs_exports"><span class="hs-identifier hs-var">abs_exports</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">ABExport GhcTc
</span><a href="#local-6989586621681162881"><span class="hs-keyword hs-var">export</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1339"></span><span>                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_ev_binds :: [TcEvBinds]
</span><a href="GHC.Hs.Binds.html#abs_ev_binds"><span class="hs-identifier hs-var">abs_ev_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681162915"><span class="hs-identifier hs-var">dfun_ev_binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681162879"><span class="hs-identifier hs-var">local_ev_binds</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1340"></span><span>                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_binds :: LHsBinds GhcTc
</span><a href="GHC.Hs.Binds.html#abs_binds"><span class="hs-identifier hs-var">abs_binds</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc
forall a. Bag a
</span><a href="GHC.Data.Bag.html#emptyBag"><span class="hs-identifier hs-var">emptyBag</span></a></span><span>
</span><span id="line-1341"></span><span>                                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_sig :: Bool
</span><a href="GHC.Hs.Binds.html#abs_sig"><span class="hs-identifier hs-var">abs_sig</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1342"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Id, LHsBind GhcTc, Implication)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162884"><span class="hs-identifier hs-var">sc_top_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; HsBindLR GhcTc GhcTc -&gt; LHsBind GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162906"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">HsBindLR GhcTc GhcTc
</span><a href="#local-6989586621681162878"><span class="hs-identifier hs-var">bind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681162901"><span class="hs-identifier hs-var">sc_implic</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1343"></span><span>
</span><span id="line-1344"></span><span class="hs-comment">-------------------</span><span>
</span><span id="line-1345"></span><span id="local-6989586621681163960"><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#checkInstConstraints"><span class="hs-identifier hs-type">checkInstConstraints</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681163960"><span class="hs-identifier hs-type">result</span></a></span><span>
</span><span id="line-1346"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#EvBindsVar"><span class="hs-identifier hs-type">EvBindsVar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621681163960"><span class="hs-identifier hs-type">result</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-1347"></span><span class="hs-comment">-- See Note [Typechecking plan for instance declarations]</span><span>
</span><span id="line-1348"></span><span id="checkInstConstraints"><span class="annot"><span class="annottext">checkInstConstraints :: forall result. TcM result -&gt; TcM (Implication, EvBindsVar, result)
</span><a href="GHC.Tc.TyCl.Instance.html#checkInstConstraints"><span class="hs-identifier hs-var hs-var">checkInstConstraints</span></a></span></span><span> </span><span id="local-6989586621681162873"><span class="annot"><span class="annottext">TcM result
</span><a href="#local-6989586621681162873"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-1349"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162872"><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681162872"><span class="hs-identifier hs-var">tclvl</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162871"><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681162871"><span class="hs-identifier hs-var">wanted</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162870"><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681162870"><span class="hs-identifier hs-var">result</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM result -&gt; TcM (TcLevel, WantedConstraints, result)
forall a. TcM a -&gt; TcM (TcLevel, WantedConstraints, a)
</span><a href="GHC.Tc.Utils.Monad.html#pushLevelAndCaptureConstraints"><span class="hs-identifier hs-var">pushLevelAndCaptureConstraints</span></a></span><span>  </span><span class="annot"><span class="annottext">(TcM result -&gt; TcM (TcLevel, WantedConstraints, result))
-&gt; TcM result -&gt; TcM (TcLevel, WantedConstraints, result)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1350"></span><span>                                    </span><span class="annot"><span class="annottext">TcM result
</span><a href="#local-6989586621681162873"><span class="hs-identifier hs-var">thing_inside</span></a></span><span>
</span><span id="line-1351"></span><span>
</span><span id="line-1352"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162868"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681162868"><span class="hs-identifier hs-var">ev_binds_var</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM EvBindsVar
</span><a href="GHC.Tc.Utils.Monad.html#newTcEvBinds"><span class="hs-identifier hs-var">newTcEvBinds</span></a></span><span>
</span><span id="line-1353"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162867"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681162867"><span class="hs-identifier hs-var">implic</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM Implication
</span><a href="GHC.Tc.Utils.TcMType.html#newImplication"><span class="hs-identifier hs-var">newImplication</span></a></span><span>
</span><span id="line-1354"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162866"><span class="annot"><span class="annottext">implic' :: Implication
</span><a href="#local-6989586621681162866"><span class="hs-identifier hs-var hs-var">implic'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681162867"><span class="hs-identifier hs-var">implic</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ic_tclvl :: TcLevel
</span><a href="GHC.Tc.Types.Constraint.html#ic_tclvl"><span class="hs-identifier hs-var">ic_tclvl</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcLevel
</span><a href="#local-6989586621681162872"><span class="hs-identifier hs-var">tclvl</span></a></span><span>
</span><span id="line-1355"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_wanted :: WantedConstraints
</span><a href="GHC.Tc.Types.Constraint.html#ic_wanted"><span class="hs-identifier hs-var">ic_wanted</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WantedConstraints
</span><a href="#local-6989586621681162871"><span class="hs-identifier hs-var">wanted</span></a></span><span>
</span><span id="line-1356"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_binds :: EvBindsVar
</span><a href="GHC.Tc.Types.Constraint.html#ic_binds"><span class="hs-identifier hs-var">ic_binds</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681162868"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-1357"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ic_info :: SkolemInfo
</span><a href="GHC.Tc.Types.Constraint.html#ic_info"><span class="hs-identifier hs-var">ic_info</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SkolemInfo
</span><a href="GHC.Tc.Types.Origin.html#InstSkol"><span class="hs-identifier hs-var">InstSkol</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1358"></span><span>
</span><span id="line-1359"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Implication, EvBindsVar, result)
-&gt; TcM (Implication, EvBindsVar, result)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681162866"><span class="hs-identifier hs-var">implic'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681162868"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">result
</span><a href="#local-6989586621681162870"><span class="hs-identifier hs-var">result</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1360"></span><span>
</span><span id="line-1361"></span><span class="hs-comment">{-
Note [Recursive superclasses]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
See #3731, #4809, #5751, #5913, #6117, #6161, which all
describe somewhat more complicated situations, but ones
encountered in practice.

See also tests tcrun020, tcrun021, tcrun033, and #11427.

----- THE PROBLEM --------
The problem is that it is all too easy to create a class whose
superclass is bottom when it should not be.

Consider the following (extreme) situation:
        class C a =&gt; D a where ...
        instance D [a] =&gt; D [a] where ...   (dfunD)
        instance C [a] =&gt; C [a] where ...   (dfunC)
Although this looks wrong (assume D [a] to prove D [a]), it is only a
more extreme case of what happens with recursive dictionaries, and it
can, just about, make sense because the methods do some work before
recursing.

To implement the dfunD we must generate code for the superclass C [a],
which we had better not get by superclass selection from the supplied
argument:
       dfunD :: forall a. D [a] -&gt; D [a]
       dfunD = \d::D [a] -&gt; MkD (scsel d) ..

Otherwise if we later encounter a situation where
we have a [Wanted] dw::D [a] we might solve it thus:
     dw := dfunD dw
Which is all fine except that now ** the superclass C is bottom **!

The instance we want is:
       dfunD :: forall a. D [a] -&gt; D [a]
       dfunD = \d::D [a] -&gt; MkD (dfunC (scsel d)) ...

----- THE SOLUTION --------
The basic solution is simple: be very careful about using superclass
selection to generate a superclass witness in a dictionary function
definition.  More precisely:

  Superclass Invariant: in every class dictionary,
                        every superclass dictionary field
                        is non-bottom

To achieve the Superclass Invariant, in a dfun definition we can
generate a guaranteed-non-bottom superclass witness from:
  (sc1) one of the dictionary arguments itself (all non-bottom)
  (sc2) an immediate superclass of a smaller dictionary
  (sc3) a call of a dfun (always returns a dictionary constructor)

The tricky case is (sc2).  We proceed by induction on the size of
the (type of) the dictionary, defined by GHC.Tc.Validity.sizeTypes.
Let's suppose we are building a dictionary of size 3, and
suppose the Superclass Invariant holds of smaller dictionaries.
Then if we have a smaller dictionary, its immediate superclasses
will be non-bottom by induction.

What does &quot;we have a smaller dictionary&quot; mean?  It might be
one of the arguments of the instance, or one of its superclasses.
Here is an example, taken from CmmExpr:
       class Ord r =&gt; UserOfRegs r a where ...
(i1)   instance UserOfRegs r a =&gt; UserOfRegs r (Maybe a) where
(i2)   instance (Ord r, UserOfRegs r CmmReg) =&gt; UserOfRegs r CmmExpr where

For (i1) we can get the (Ord r) superclass by selection from (UserOfRegs r a),
since it is smaller than the thing we are building (UserOfRegs r (Maybe a).

But for (i2) that isn't the case, so we must add an explicit, and
perhaps surprising, (Ord r) argument to the instance declaration.

Here's another example from #6161:

       class       Super a =&gt; Duper a  where ...
       class Duper (Fam a) =&gt; Foo a    where ...
(i3)   instance Foo a =&gt; Duper (Fam a) where ...
(i4)   instance              Foo Float where ...

It would be horribly wrong to define
   dfDuperFam :: Foo a -&gt; Duper (Fam a)  -- from (i3)
   dfDuperFam d = MkDuper (sc_sel1 (sc_sel2 d)) ...

   dfFooFloat :: Foo Float               -- from (i4)
   dfFooFloat = MkFoo (dfDuperFam dfFooFloat) ...

Now the Super superclass of Duper is definitely bottom!

This won't happen because when processing (i3) we can use the
superclasses of (Foo a), which is smaller, namely Duper (Fam a).  But
that is *not* smaller than the target so we can't take *its*
superclasses.  As a result the program is rightly rejected, unless you
add (Super (Fam a)) to the context of (i3).

Note [Solving superclass constraints]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
How do we ensure that every superclass witness is generated by
one of (sc1) (sc2) or (sc3) in Note [Recursive superclasses].
Answer:

  * Superclass &quot;wanted&quot; constraints have CtOrigin of (ScOrigin size)
    where 'size' is the size of the instance declaration. e.g.
          class C a =&gt; D a where...
          instance blah =&gt; D [a] where ...
    The wanted superclass constraint for C [a] has origin
    ScOrigin size, where size = size( D [a] ).

  * (sc1) When we rewrite such a wanted constraint, it retains its
    origin.  But if we apply an instance declaration, we can set the
    origin to (ScOrigin infinity), thus lifting any restrictions by
    making prohibitedSuperClassSolve return False.

  * (sc2) ScOrigin wanted constraints can't be solved from a
    superclass selection, except at a smaller type.  This test is
    implemented by GHC.Tc.Solver.Interact.prohibitedSuperClassSolve

  * The &quot;given&quot; constraints of an instance decl have CtOrigin
    GivenOrigin InstSkol.

  * When we make a superclass selection from InstSkol we use
    a SkolemInfo of (InstSC size), where 'size' is the size of
    the constraint whose superclass we are taking.  A similarly
    when taking the superclass of an InstSC.  This is implemented
    in GHC.Tc.Solver.Canonical.newSCWorkFromFlavored

Note [Silent superclass arguments] (historical interest only)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NB1: this note describes our *old* solution to the
     recursive-superclass problem. I'm keeping the Note
     for now, just as institutional memory.
     However, the code for silent superclass arguments
     was removed in late Dec 2014

NB2: the silent-superclass solution introduced new problems
     of its own, in the form of instance overlap.  Tests
     SilentParametersOverlapping, T5051, and T7862 are examples

NB3: the silent-superclass solution also generated tons of
     extra dictionaries.  For example, in monad-transformer
     code, when constructing a Monad dictionary you had to pass
     an Applicative dictionary; and to construct that you need
     a Functor dictionary. Yet these extra dictionaries were
     often never used.  Test T3064 compiled *far* faster after
     silent superclasses were eliminated.

Our solution to this problem &quot;silent superclass arguments&quot;.  We pass
to each dfun some ``silent superclass arguments&#8217;&#8217;, which are the
immediate superclasses of the dictionary we are trying to
construct. In our example:
       dfun :: forall a. C [a] -&gt; D [a] -&gt; D [a]
       dfun = \(dc::C [a]) (dd::D [a]) -&gt; DOrd dc ...
Notice the extra (dc :: C [a]) argument compared to the previous version.

This gives us:

     -----------------------------------------------------------
     DFun Superclass Invariant
     ~~~~~~~~~~~~~~~~~~~~~~~~
     In the body of a DFun, every superclass argument to the
     returned dictionary is
       either   * one of the arguments of the DFun,
       or       * constant, bound at top level
     -----------------------------------------------------------

This net effect is that it is safe to treat a dfun application as
wrapping a dictionary constructor around its arguments (in particular,
a dfun never picks superclasses from the arguments under the
dictionary constructor). No superclass is hidden inside a dfun
application.

The extra arguments required to satisfy the DFun Superclass Invariant
always come first, and are called the &quot;silent&quot; arguments.  You can
find out how many silent arguments there are using Id.dfunNSilent;
and then you can just drop that number of arguments to see the ones
that were in the original instance declaration.

DFun types are built (only) by MkId.mkDictFunId, so that is where we
decide what silent arguments are to be added.
-}</span><span>
</span><span id="line-1540"></span><span>
</span><span id="line-1541"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
      Type-checking an instance method
*                                                                      *
************************************************************************

tcMethod
- Make the method bindings, as a [(NonRec, HsBinds)], one per method
- Remembering to use fresh Name (the instance method Name) as the binder
- Bring the instance method Ids into scope, for the benefit of tcInstSig
- Use sig_fn mapping instance method Name -&gt; instance tyvars
- Ditto prag_fn
- Use tcValBinds to do the checking
-}</span><span>
</span><span id="line-1556"></span><span>
</span><span id="line-1557"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcMethods"><span class="hs-identifier hs-type">tcMethods</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#DFunId"><span class="hs-identifier hs-type">DFunId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span>
</span><span id="line-1558"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1559"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1560"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcEvBinds"><span class="hs-identifier hs-type">TcEvBinds</span></a></span><span>
</span><span id="line-1561"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#TcSpecPrag"><span class="hs-identifier hs-type">TcSpecPrag</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Sig.html#TcPragEnv"><span class="hs-identifier hs-type">TcPragEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1562"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.Class.html#ClassOpItem"><span class="hs-identifier hs-type">ClassOpItem</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1563"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstBindings"><span class="hs-identifier hs-type">InstBindings</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span>
</span><span id="line-1564"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html#Bag"><span class="hs-identifier hs-type">Bag</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1565"></span><span>        </span><span class="hs-comment">-- The returned inst_meth_ids all have types starting</span><span>
</span><span id="line-1566"></span><span>        </span><span class="hs-comment">--      forall tvs. theta =&gt; ...</span><span>
</span><span id="line-1567"></span><span id="tcMethods"><span class="annot"><span class="annottext">tcMethods :: Id
-&gt; Class
-&gt; [Id]
-&gt; [Id]
-&gt; [PredType]
-&gt; TcEvBinds
-&gt; ([Located TcSpecPrag], TcPragEnv)
-&gt; [ClassOpItem]
-&gt; InstBindings (GhcPass 'Renamed)
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
</span><a href="GHC.Tc.TyCl.Instance.html#tcMethods"><span class="hs-identifier hs-var hs-var">tcMethods</span></a></span></span><span> </span><span id="local-6989586621681162865"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162865"><span class="hs-identifier hs-var">dfun_id</span></a></span></span><span> </span><span id="local-6989586621681162864"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162864"><span class="hs-identifier hs-var">clas</span></a></span></span><span> </span><span id="local-6989586621681162863"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162863"><span class="hs-identifier hs-var">tyvars</span></a></span></span><span> </span><span id="local-6989586621681162862"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162862"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span></span><span> </span><span id="local-6989586621681162861"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162861"><span class="hs-identifier hs-var">inst_tys</span></a></span></span><span>
</span><span id="line-1568"></span><span>                  </span><span id="local-6989586621681162860"><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681162860"><span class="hs-identifier hs-var">dfun_ev_binds</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162859"><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162859"><span class="hs-identifier hs-var">spec_inst_prags</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162858"><span class="annot"><span class="annottext">TcPragEnv
</span><a href="#local-6989586621681162858"><span class="hs-identifier hs-var">prag_fn</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681162857"><span class="annot"><span class="annottext">[ClassOpItem]
</span><a href="#local-6989586621681162857"><span class="hs-identifier hs-var">op_items</span></a></span></span><span>
</span><span id="line-1569"></span><span>                  </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstBindings"><span class="hs-identifier hs-type">InstBindings</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ib_binds :: forall a. InstBindings a -&gt; LHsBinds a
</span><a href="GHC.Tc.Utils.Env.html#ib_binds"><span class="hs-identifier hs-var">ib_binds</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681162856"><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681162856"><span class="hs-identifier hs-var">binds</span></a></span></span><span>
</span><span id="line-1570"></span><span>                                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ib_tyvars :: forall a. InstBindings a -&gt; [Name]
</span><a href="GHC.Tc.Utils.Env.html#ib_tyvars"><span class="hs-identifier hs-var">ib_tyvars</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681162855"><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681162855"><span class="hs-identifier hs-var">lexical_tvs</span></a></span></span><span>
</span><span id="line-1571"></span><span>                                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ib_pragmas :: forall a. InstBindings a -&gt; [LSig a]
</span><a href="GHC.Tc.Utils.Env.html#ib_pragmas"><span class="hs-identifier hs-var">ib_pragmas</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681162854"><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162854"><span class="hs-identifier hs-var">sigs</span></a></span></span><span>
</span><span id="line-1572"></span><span>                                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ib_extensions :: forall a. InstBindings a -&gt; [Extension]
</span><a href="GHC.Tc.Utils.Env.html#ib_extensions"><span class="hs-identifier hs-var">ib_extensions</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681162853"><span class="annot"><span class="annottext">[Extension]
</span><a href="#local-6989586621681162853"><span class="hs-identifier hs-var">exts</span></a></span></span><span>
</span><span id="line-1573"></span><span>                                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ib_derived :: forall a. InstBindings a -&gt; Bool
</span><a href="GHC.Tc.Utils.Env.html#ib_derived"><span class="hs-identifier hs-var">ib_derived</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681162852"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162852"><span class="hs-identifier hs-var">is_derived</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1574"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(Name, Id)]
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
forall r. [(Name, Id)] -&gt; TcM r -&gt; TcM r
</span><a href="GHC.Tc.Utils.Env.html#tcExtendNameTyVarEnv"><span class="hs-identifier hs-var">tcExtendNameTyVarEnv</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681162855"><span class="hs-identifier hs-var">lexical_tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; [Id] -&gt; [(Name, Id)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162863"><span class="hs-identifier hs-var">tyvars</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcM ([Id], LHsBinds GhcTc, Bag Implication)
 -&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication))
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1575"></span><span>       </span><span class="hs-comment">-- The lexical_tvs scope over the 'where' part</span><span>
</span><span id="line-1576"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcInstMeth&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162854"><span class="hs-identifier hs-var">sigs</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681162856"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1577"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcRn ()
</span><a href="#local-6989586621681162851"><span class="hs-identifier hs-var">checkMinimalDefinition</span></a></span><span>
</span><span id="line-1578"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcRn ()
</span><a href="#local-6989586621681162850"><span class="hs-identifier hs-var">checkMethBindMembership</span></a></span><span>
</span><span id="line-1579"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162849"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162849"><span class="hs-identifier hs-var">ids</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162848"><span class="annot"><span class="annottext">[LHsBind GhcTc]
</span><a href="#local-6989586621681162848"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162847"><span class="annot"><span class="annottext">[Maybe Implication]
</span><a href="#local-6989586621681162847"><span class="hs-identifier hs-var">mb_implics</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Extension]
-&gt; TcM ([Id], [LHsBind GhcTc], [Maybe Implication])
-&gt; TcM ([Id], [LHsBind GhcTc], [Maybe Implication])
forall a. [Extension] -&gt; TcM a -&gt; TcM a
</span><a href="#local-6989586621681162846"><span class="hs-identifier hs-var">set_exts</span></a></span><span> </span><span class="annot"><span class="annottext">[Extension]
</span><a href="#local-6989586621681162853"><span class="hs-identifier hs-var">exts</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM ([Id], [LHsBind GhcTc], [Maybe Implication])
 -&gt; TcM ([Id], [LHsBind GhcTc], [Maybe Implication]))
-&gt; TcM ([Id], [LHsBind GhcTc], [Maybe Implication])
-&gt; TcM ([Id], [LHsBind GhcTc], [Maybe Implication])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1580"></span><span>                                     </span><span class="annot"><span class="annottext">TcM ([Id], [LHsBind GhcTc], [Maybe Implication])
-&gt; TcM ([Id], [LHsBind GhcTc], [Maybe Implication])
forall a. TcM a -&gt; TcM a
</span><a href="#local-6989586621681162845"><span class="hs-identifier hs-var">unset_warnings_deriving</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM ([Id], [LHsBind GhcTc], [Maybe Implication])
 -&gt; TcM ([Id], [LHsBind GhcTc], [Maybe Implication]))
-&gt; TcM ([Id], [LHsBind GhcTc], [Maybe Implication])
-&gt; TcM ([Id], [LHsBind GhcTc], [Maybe Implication])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1581"></span><span>                                     </span><span class="annot"><span class="annottext">(ClassOpItem
 -&gt; IOEnv
      (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication))
-&gt; [ClassOpItem]
-&gt; TcM ([Id], [LHsBind GhcTc], [Maybe Implication])
forall (m :: * -&gt; *) a b c d.
Monad m =&gt;
(a -&gt; m (b, c, d)) -&gt; [a] -&gt; m ([b], [c], [d])
</span><a href="GHC.Utils.Monad.html#mapAndUnzip3M"><span class="hs-identifier hs-var">mapAndUnzip3M</span></a></span><span> </span><span class="annot"><span class="annottext">ClassOpItem
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="#local-6989586621681162844"><span class="hs-identifier hs-var">tc_item</span></a></span><span> </span><span class="annot"><span class="annottext">[ClassOpItem]
</span><a href="#local-6989586621681162857"><span class="hs-identifier hs-var">op_items</span></a></span><span>
</span><span id="line-1582"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([Id], LHsBinds GhcTc, Bag Implication)
-&gt; TcM ([Id], LHsBinds GhcTc, Bag Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162849"><span class="hs-identifier hs-var">ids</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[LHsBind GhcTc] -&gt; LHsBinds GhcTc
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="annot"><span class="annottext">[LHsBind GhcTc]
</span><a href="#local-6989586621681162848"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Implication] -&gt; Bag Implication
forall a. [a] -&gt; Bag a
</span><a href="GHC.Data.Bag.html#listToBag"><span class="hs-identifier hs-var">listToBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Maybe Implication] -&gt; [Implication]
forall a. [Maybe a] -&gt; [a]
</span><a href="../../base/src/Data.Maybe.html#catMaybes"><span class="hs-identifier hs-var">catMaybes</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe Implication]
</span><a href="#local-6989586621681162847"><span class="hs-identifier hs-var">mb_implics</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1583"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1584"></span><span>    </span><span id="local-6989586621681163947"><span class="annot"><a href="#local-6989586621681162846"><span class="hs-identifier hs-type">set_exts</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#Extension"><span class="hs-identifier hs-type">LangExt.Extension</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681163947"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681163947"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-1585"></span><span>    </span><span id="local-6989586621681162846"><span class="annot"><span class="annottext">set_exts :: forall a. [Extension] -&gt; TcM a -&gt; TcM a
</span><a href="#local-6989586621681162846"><span class="hs-identifier hs-var hs-var">set_exts</span></a></span></span><span> </span><span id="local-6989586621681162842"><span class="annot"><span class="annottext">[Extension]
</span><a href="#local-6989586621681162842"><span class="hs-identifier hs-var">es</span></a></span></span><span> </span><span id="local-6989586621681162841"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681162841"><span class="hs-identifier hs-var">thing</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Extension -&gt; TcM a -&gt; TcM a) -&gt; TcM a -&gt; [Extension] -&gt; TcM a
forall (t :: * -&gt; *) a b.
Foldable t =&gt;
(a -&gt; b -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldr"><span class="hs-identifier hs-var">foldr</span></a></span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcM a -&gt; TcM a
forall gbl lcl a. Extension -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#setXOptM"><span class="hs-identifier hs-var">setXOptM</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681162841"><span class="hs-identifier hs-var">thing</span></a></span><span> </span><span class="annot"><span class="annottext">[Extension]
</span><a href="#local-6989586621681162842"><span class="hs-identifier hs-var">es</span></a></span><span>
</span><span id="line-1586"></span><span>
</span><span id="line-1587"></span><span>    </span><span class="hs-comment">-- See Note [Avoid -Winaccessible-code when deriving]</span><span>
</span><span id="line-1588"></span><span>    </span><span id="local-6989586621681162838"><span class="annot"><a href="#local-6989586621681162845"><span class="hs-identifier hs-type">unset_warnings_deriving</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681162838"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681162838"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-1589"></span><span>    </span><span id="local-6989586621681162845"><span class="annot"><span class="annottext">unset_warnings_deriving :: forall a. TcM a -&gt; TcM a
</span><a href="#local-6989586621681162845"><span class="hs-identifier hs-var hs-var">unset_warnings_deriving</span></a></span></span><span>
</span><span id="line-1590"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162852"><span class="hs-identifier hs-var">is_derived</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WarningFlag
-&gt; TcRnIf TcGblEnv TcLclEnv a -&gt; TcRnIf TcGblEnv TcLclEnv a
forall gbl lcl a.
WarningFlag -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#unsetWOptM"><span class="hs-identifier hs-var">unsetWOptM</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnInaccessibleCode"><span class="hs-identifier hs-var">Opt_WarnInaccessibleCode</span></a></span><span>
</span><span id="line-1591"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv a -&gt; TcRnIf TcGblEnv TcLclEnv a
forall a. a -&gt; a
</span><a href="../../base/src/GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-1592"></span><span>
</span><span id="line-1593"></span><span>    </span><span id="local-6989586621681162834"><span class="annot"><span class="annottext">hs_sig_fn :: HsSigFun
</span><a href="#local-6989586621681162834"><span class="hs-identifier hs-var hs-var">hs_sig_fn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)] -&gt; HsSigFun
</span><a href="GHC.Tc.TyCl.Class.html#mkHsSigFun"><span class="hs-identifier hs-var">mkHsSigFun</span></a></span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162854"><span class="hs-identifier hs-var">sigs</span></a></span><span>
</span><span id="line-1594"></span><span>    </span><span id="local-6989586621681162833"><span class="annot"><span class="annottext">inst_loc :: SrcSpan
</span><a href="#local-6989586621681162833"><span class="hs-identifier hs-var hs-var">inst_loc</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SrcSpan
forall a. NamedThing a =&gt; a -&gt; SrcSpan
</span><a href="GHC.Types.Name.html#getSrcSpan"><span class="hs-identifier hs-var">getSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162865"><span class="hs-identifier hs-var">dfun_id</span></a></span><span>
</span><span id="line-1595"></span><span>
</span><span id="line-1596"></span><span>    </span><span class="hs-comment">----------------------</span><span>
</span><span id="line-1597"></span><span>    </span><span class="annot"><a href="#local-6989586621681162844"><span class="hs-identifier hs-type">tc_item</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#ClassOpItem"><span class="hs-identifier hs-type">ClassOpItem</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBind"><span class="hs-identifier hs-type">LHsBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1598"></span><span>    </span><span id="local-6989586621681162844"><span class="annot"><span class="annottext">tc_item :: ClassOpItem
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="#local-6989586621681162844"><span class="hs-identifier hs-var hs-var">tc_item</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162832"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162832"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162831"><span class="annot"><span class="annottext">DefMethInfo
</span><a href="#local-6989586621681162831"><span class="hs-identifier hs-var">dm_info</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1599"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162830"><span class="annot"><span class="annottext">GenLocated SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
</span><a href="#local-6989586621681162830"><span class="hs-identifier hs-var">user_bind</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162829"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162829"><span class="hs-identifier hs-var">bndr_loc</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162828"><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162828"><span class="hs-identifier hs-var">prags</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name
-&gt; LHsBinds (GhcPass 'Renamed)
-&gt; TcPragEnv
-&gt; Maybe
     (GenLocated
        SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)),
      SrcSpan, [LSig (GhcPass 'Renamed)])
</span><a href="GHC.Tc.TyCl.Class.html#findMethodBind"><span class="hs-identifier hs-var">findMethodBind</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162832"><span class="hs-identifier hs-var">sel_id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681162856"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="annot"><span class="annottext">TcPragEnv
</span><a href="#local-6989586621681162858"><span class="hs-identifier hs-var">prag_fn</span></a></span><span>
</span><span id="line-1600"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class
-&gt; [Id]
-&gt; [Id]
-&gt; [PredType]
-&gt; TcEvBinds
-&gt; Bool
-&gt; HsSigFun
-&gt; [Located TcSpecPrag]
-&gt; [LSig (GhcPass 'Renamed)]
-&gt; Id
-&gt; GenLocated
     SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
-&gt; SrcSpan
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="GHC.Tc.TyCl.Instance.html#tcMethodBody"><span class="hs-identifier hs-var">tcMethodBody</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162864"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162863"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162862"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162861"><span class="hs-identifier hs-var">inst_tys</span></a></span><span>
</span><span id="line-1601"></span><span>                              </span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681162860"><span class="hs-identifier hs-var">dfun_ev_binds</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162852"><span class="hs-identifier hs-var">is_derived</span></a></span><span> </span><span class="annot"><span class="annottext">HsSigFun
</span><a href="#local-6989586621681162834"><span class="hs-identifier hs-var">hs_sig_fn</span></a></span><span>
</span><span id="line-1602"></span><span>                              </span><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162859"><span class="hs-identifier hs-var">spec_inst_prags</span></a></span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162828"><span class="hs-identifier hs-var">prags</span></a></span><span>
</span><span id="line-1603"></span><span>                              </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162832"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
</span><a href="#local-6989586621681162830"><span class="hs-identifier hs-var">user_bind</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162829"><span class="hs-identifier hs-var">bndr_loc</span></a></span><span>
</span><span id="line-1604"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1605"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tc_def&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162832"><span class="hs-identifier hs-var">sel_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1606"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; DefMethInfo
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="#local-6989586621681162825"><span class="hs-identifier hs-var">tc_default</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162832"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">DefMethInfo
</span><a href="#local-6989586621681162831"><span class="hs-identifier hs-var">dm_info</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1607"></span><span>
</span><span id="line-1608"></span><span>    </span><span class="hs-comment">----------------------</span><span>
</span><span id="line-1609"></span><span>    </span><span class="annot"><a href="#local-6989586621681162825"><span class="hs-identifier hs-type">tc_default</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#DefMethInfo"><span class="hs-identifier hs-type">DefMethInfo</span></a></span><span>
</span><span id="line-1610"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBind"><span class="hs-identifier hs-type">LHsBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1611"></span><span>
</span><span id="line-1612"></span><span>    </span><span id="local-6989586621681162825"><span class="annot"><span class="annottext">tc_default :: Id
-&gt; DefMethInfo
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="#local-6989586621681162825"><span class="hs-identifier hs-var hs-var">tc_default</span></a></span></span><span> </span><span id="local-6989586621681162823"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162823"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162822"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162822"><span class="hs-identifier hs-var">dm_name</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DefMethSpec PredType
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1613"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162821"><span class="annot"><span class="annottext">GenLocated SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
</span><a href="#local-6989586621681162821"><span class="hs-identifier hs-var">meth_bind</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162820"><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162820"><span class="hs-identifier hs-var">inline_prags</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id
-&gt; Class
-&gt; Id
-&gt; Name
-&gt; TcM
     (GenLocated
        SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)),
      [LSig (GhcPass 'Renamed)])
</span><a href="GHC.Tc.TyCl.Instance.html#mkDefMethBind"><span class="hs-identifier hs-var">mkDefMethBind</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162865"><span class="hs-identifier hs-var">dfun_id</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162864"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162823"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162822"><span class="hs-identifier hs-var">dm_name</span></a></span><span>
</span><span id="line-1614"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Class
-&gt; [Id]
-&gt; [Id]
-&gt; [PredType]
-&gt; TcEvBinds
-&gt; Bool
-&gt; HsSigFun
-&gt; [Located TcSpecPrag]
-&gt; [LSig (GhcPass 'Renamed)]
-&gt; Id
-&gt; GenLocated
     SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
-&gt; SrcSpan
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="GHC.Tc.TyCl.Instance.html#tcMethodBody"><span class="hs-identifier hs-var">tcMethodBody</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162864"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162863"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162862"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162861"><span class="hs-identifier hs-var">inst_tys</span></a></span><span>
</span><span id="line-1615"></span><span>                          </span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681162860"><span class="hs-identifier hs-var">dfun_ev_binds</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162852"><span class="hs-identifier hs-var">is_derived</span></a></span><span> </span><span class="annot"><span class="annottext">HsSigFun
</span><a href="#local-6989586621681162834"><span class="hs-identifier hs-var">hs_sig_fn</span></a></span><span>
</span><span id="line-1616"></span><span>                          </span><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162859"><span class="hs-identifier hs-var">spec_inst_prags</span></a></span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162820"><span class="hs-identifier hs-var">inline_prags</span></a></span><span>
</span><span id="line-1617"></span><span>                          </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162823"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
</span><a href="#local-6989586621681162821"><span class="hs-identifier hs-var">meth_bind</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162833"><span class="hs-identifier hs-var">inst_loc</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1618"></span><span>
</span><span id="line-1619"></span><span>    </span><span class="annot"><a href="#local-6989586621681162825"><span class="hs-identifier hs-var">tc_default</span></a></span><span> </span><span id="local-6989586621681162818"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162818"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span> </span><span class="annot"><span class="annottext">DefMethInfo
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>     </span><span class="hs-comment">-- No default method at all</span><span>
</span><span id="line-1620"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tc_def: warn&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162818"><span class="hs-identifier hs-var">sel_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1621"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162817"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162817"><span class="hs-identifier hs-var">meth_id</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Class -&gt; [Id] -&gt; [Id] -&gt; [PredType] -&gt; Id -&gt; TcM (Id, Id)
</span><a href="GHC.Tc.TyCl.Instance.html#mkMethIds"><span class="hs-identifier hs-var">mkMethIds</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162864"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162863"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162862"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span>
</span><span id="line-1622"></span><span>                                       </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162861"><span class="hs-identifier hs-var">inst_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162818"><span class="hs-identifier hs-var">sel_id</span></a></span><span>
</span><span id="line-1623"></span><span>           </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162815"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681162815"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-1624"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162813"><span class="annot"><span class="annottext">meth_bind :: LHsBind GhcTc
</span><a href="#local-6989586621681162813"><span class="hs-identifier hs-var hs-var">meth_bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IdP GhcTc -&gt; LHsExpr GhcTc -&gt; LHsBind GhcTc
forall (p :: Pass).
IdP (GhcPass p) -&gt; LHsExpr (GhcPass p) -&gt; LHsBind (GhcPass p)
</span><a href="GHC.Hs.Utils.html#mkVarBind"><span class="hs-identifier hs-var">mkVarBind</span></a></span><span> </span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681162817"><span class="hs-identifier hs-var">meth_id</span></a></span><span> </span><span class="annot"><span class="annottext">(LHsExpr GhcTc -&gt; LHsBind GhcTc) -&gt; LHsExpr GhcTc -&gt; LHsBind GhcTc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1625"></span><span>                             </span><span class="annot"><span class="annottext">HsWrapper -&gt; LHsExpr GhcTc -&gt; LHsExpr GhcTc
</span><a href="GHC.Hs.Utils.html#mkLHsWrap"><span class="hs-identifier hs-var">mkLHsWrap</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162811"><span class="hs-identifier hs-var">lam_wrapper</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; LHsExpr GhcTc
</span><a href="#local-6989586621681162810"><span class="hs-identifier hs-var">error_rhs</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681162815"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1626"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Id, LHsBind GhcTc, Maybe Implication)
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162817"><span class="hs-identifier hs-var">meth_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LHsBind GhcTc
</span><a href="#local-6989586621681162813"><span class="hs-identifier hs-var">meth_bind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe Implication
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1627"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1628"></span><span>        </span><span id="local-6989586621681162810"><span class="annot"><span class="annottext">error_rhs :: DynFlags -&gt; LHsExpr GhcTc
</span><a href="#local-6989586621681162810"><span class="hs-identifier hs-var hs-var">error_rhs</span></a></span></span><span> </span><span id="local-6989586621681162809"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681162809"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; HsExpr GhcTc -&gt; LHsExpr GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162833"><span class="hs-identifier hs-var">inst_loc</span></a></span><span> </span><span class="annot"><span class="annottext">(HsExpr GhcTc -&gt; LHsExpr GhcTc) -&gt; HsExpr GhcTc -&gt; LHsExpr GhcTc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">XApp GhcTc -&gt; LHsExpr GhcTc -&gt; LHsExpr GhcTc -&gt; HsExpr GhcTc
forall p. XApp p -&gt; LHsExpr p -&gt; LHsExpr p -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsApp"><span class="hs-identifier hs-var">HsApp</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XApp GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="annot"><span class="annottext">LHsExpr GhcTc
</span><a href="#local-6989586621681162808"><span class="hs-identifier hs-var">error_fun</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; LHsExpr GhcTc
</span><a href="#local-6989586621681162807"><span class="hs-identifier hs-var">error_msg</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681162809"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1629"></span><span>        </span><span id="local-6989586621681162808"><span class="annot"><span class="annottext">error_fun :: LHsExpr GhcTc
</span><a href="#local-6989586621681162808"><span class="hs-identifier hs-var hs-var">error_fun</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; HsExpr GhcTc -&gt; LHsExpr GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162833"><span class="hs-identifier hs-var">inst_loc</span></a></span><span> </span><span class="annot"><span class="annottext">(HsExpr GhcTc -&gt; LHsExpr GhcTc) -&gt; HsExpr GhcTc -&gt; LHsExpr GhcTc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1630"></span><span>                       </span><span class="annot"><span class="annottext">HsWrapper -&gt; Id -&gt; HsExpr GhcTc
</span><a href="GHC.Tc.TyCl.Instance.html#wrapId"><span class="hs-identifier hs-var">wrapId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[PredType] -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpTyApps"><span class="hs-identifier hs-var">mkWpTyApps</span></a></span><span>
</span><span id="line-1631"></span><span>                                </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; PredType -&gt; PredType
PredType -&gt; PredType
</span><a href="GHC.Core.Type.html#getRuntimeRep"><span class="hs-identifier hs-var">getRuntimeRep</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162805"><span class="hs-identifier hs-var">meth_tau</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162805"><span class="hs-identifier hs-var">meth_tau</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1632"></span><span>                              </span><span class="annot"><span class="annottext">Id
</span><a href="GHC.Core.Make.html#nO_METHOD_BINDING_ERROR_ID"><span class="hs-identifier hs-var">nO_METHOD_BINDING_ERROR_ID</span></a></span><span>
</span><span id="line-1633"></span><span>        </span><span id="local-6989586621681162807"><span class="annot"><span class="annottext">error_msg :: DynFlags -&gt; LHsExpr GhcTc
</span><a href="#local-6989586621681162807"><span class="hs-identifier hs-var hs-var">error_msg</span></a></span></span><span> </span><span id="local-6989586621681162804"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681162804"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; HsExpr GhcTc -&gt; LHsExpr GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162833"><span class="hs-identifier hs-var">inst_loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XLitE GhcTc -&gt; HsLit GhcTc -&gt; HsExpr GhcTc
forall p. XLitE p -&gt; HsLit p -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsLit"><span class="hs-identifier hs-var">HsLit</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XLitE GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XHsStringPrim GhcTc -&gt; ByteString -&gt; HsLit GhcTc
forall x. XHsStringPrim x -&gt; ByteString -&gt; HsLit x
</span><a href="GHC.Hs.Lit.html#HsStringPrim"><span class="hs-identifier hs-var">HsStringPrim</span></a></span><span> </span><span class="annot"><span class="annottext">SourceText
XHsStringPrim GhcTc
</span><a href="GHC.Types.Basic.html#NoSourceText"><span class="hs-identifier hs-var">NoSourceText</span></a></span><span>
</span><span id="line-1634"></span><span>                                              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; ByteString
</span><a href="GHC.Data.FastString.html#unsafeMkByteString"><span class="hs-identifier hs-var">unsafeMkByteString</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; String
</span><a href="#local-6989586621681162799"><span class="hs-identifier hs-var">error_string</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681162804"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1635"></span><span>        </span><span id="local-6989586621681162805"><span class="annot"><span class="annottext">meth_tau :: PredType
</span><a href="#local-6989586621681162805"><span class="hs-identifier hs-var hs-var">meth_tau</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [PredType] -&gt; PredType
</span><a href="GHC.Core.Predicate.html#classMethodInstTy"><span class="hs-identifier hs-var">classMethodInstTy</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162818"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162861"><span class="hs-identifier hs-var">inst_tys</span></a></span><span>
</span><span id="line-1636"></span><span>        </span><span id="local-6989586621681162799"><span class="annot"><span class="annottext">error_string :: DynFlags -&gt; String
</span><a href="#local-6989586621681162799"><span class="hs-identifier hs-var hs-var">error_string</span></a></span></span><span> </span><span id="local-6989586621681162798"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681162798"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; SDoc -&gt; String
</span><a href="GHC.Utils.Outputable.html#showSDoc"><span class="hs-identifier hs-var">showSDoc</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681162798"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-1637"></span><span>                              </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hcat"><span class="hs-identifier hs-var">hcat</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">SrcSpan -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162833"><span class="hs-identifier hs-var">inst_loc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#vbar"><span class="hs-identifier hs-var">vbar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162818"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1638"></span><span>        </span><span id="local-6989586621681162811"><span class="annot"><span class="annottext">lam_wrapper :: HsWrapper
</span><a href="#local-6989586621681162811"><span class="hs-identifier hs-var hs-var">lam_wrapper</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpTyLams"><span class="hs-identifier hs-var">mkWpTyLams</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162863"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper -&gt; HsWrapper -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#%3C.%3E"><span class="hs-operator hs-var">&lt;.&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#mkWpLams"><span class="hs-identifier hs-var">mkWpLams</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162862"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span>
</span><span id="line-1639"></span><span>
</span><span id="line-1640"></span><span>    </span><span class="hs-comment">----------------------</span><span>
</span><span id="line-1641"></span><span>    </span><span class="hs-comment">-- Check if one of the minimal complete definitions is satisfied</span><span>
</span><span id="line-1642"></span><span>    </span><span id="local-6989586621681162851"><span class="annot"><span class="annottext">checkMinimalDefinition :: TcRn ()
</span><a href="#local-6989586621681162851"><span class="hs-identifier hs-var hs-var">checkMinimalDefinition</span></a></span></span><span>
</span><span id="line-1643"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (BooleanFormula Name)
-&gt; (BooleanFormula Name -&gt; TcRn ()) -&gt; TcRn ()
forall (m :: * -&gt; *) a. Monad m =&gt; Maybe a -&gt; (a -&gt; m ()) -&gt; m ()
</span><a href="GHC.Data.Maybe.html#whenIsJust"><span class="hs-identifier hs-var">whenIsJust</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Name -&gt; Bool)
-&gt; BooleanFormula Name -&gt; Maybe (BooleanFormula Name)
forall a.
Eq a =&gt;
(a -&gt; Bool) -&gt; BooleanFormula a -&gt; Maybe (BooleanFormula a)
</span><a href="GHC.Data.BooleanFormula.html#isUnsatisfied"><span class="hs-identifier hs-var">isUnsatisfied</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool
</span><a href="#local-6989586621681162791"><span class="hs-identifier hs-var">methodExists</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; BooleanFormula Name
</span><a href="GHC.Core.Class.html#classMinimalDef"><span class="hs-identifier hs-var">classMinimalDef</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162864"><span class="hs-identifier hs-var">clas</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((BooleanFormula Name -&gt; TcRn ()) -&gt; TcRn ())
-&gt; (BooleanFormula Name -&gt; TcRn ()) -&gt; TcRn ()
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1644"></span><span>        </span><span class="annot"><span class="annottext">BooleanFormula Name -&gt; TcRn ()
</span><a href="GHC.Tc.TyCl.Instance.html#warnUnsatisfiedMinimalDefinition"><span class="hs-identifier hs-var">warnUnsatisfiedMinimalDefinition</span></a></span><span>
</span><span id="line-1645"></span><span>
</span><span id="line-1646"></span><span>    </span><span id="local-6989586621681162791"><span class="annot"><span class="annottext">methodExists :: Name -&gt; Bool
</span><a href="#local-6989586621681162791"><span class="hs-identifier hs-var hs-var">methodExists</span></a></span></span><span> </span><span id="local-6989586621681162788"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162788"><span class="hs-identifier hs-var">meth</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe
  (GenLocated
     SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)),
   SrcSpan, [LSig (GhcPass 'Renamed)])
-&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name
-&gt; LHsBinds (GhcPass 'Renamed)
-&gt; TcPragEnv
-&gt; Maybe
     (GenLocated
        SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)),
      SrcSpan, [LSig (GhcPass 'Renamed)])
</span><a href="GHC.Tc.TyCl.Class.html#findMethodBind"><span class="hs-identifier hs-var">findMethodBind</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162788"><span class="hs-identifier hs-var">meth</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681162856"><span class="hs-identifier hs-var">binds</span></a></span><span> </span><span class="annot"><span class="annottext">TcPragEnv
</span><a href="#local-6989586621681162858"><span class="hs-identifier hs-var">prag_fn</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1647"></span><span>
</span><span id="line-1648"></span><span>    </span><span class="hs-comment">----------------------</span><span>
</span><span id="line-1649"></span><span>    </span><span class="hs-comment">-- Check if any method bindings do not correspond to the class.</span><span>
</span><span id="line-1650"></span><span>    </span><span class="hs-comment">-- See Note [Mismatched class methods and associated type families].</span><span>
</span><span id="line-1651"></span><span>    </span><span id="local-6989586621681162850"><span class="annot"><span class="annottext">checkMethBindMembership :: TcRn ()
</span><a href="#local-6989586621681162850"><span class="hs-identifier hs-var hs-var">checkMethBindMembership</span></a></span></span><span>
</span><span id="line-1652"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; TcRn ()) -&gt; [Name] -&gt; TcRn ()
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Foldable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m ()
</span><a href="../../base/src/Data.Foldable.html#mapM_"><span class="hs-identifier hs-var">mapM_</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#addErrTc"><span class="hs-identifier hs-var">addErrTc</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; TcRn ()) -&gt; (Name -&gt; SDoc) -&gt; Name -&gt; TcRn ()
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; Name -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; Name -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Class.html#badMethodErr"><span class="hs-identifier hs-var">badMethodErr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162864"><span class="hs-identifier hs-var">clas</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681162784"><span class="hs-identifier hs-var">mismatched_meths</span></a></span><span>
</span><span id="line-1653"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-1654"></span><span>        </span><span id="local-6989586621681162783"><span class="annot"><span class="annottext">bind_nms :: [Name]
</span><a href="#local-6989586621681162783"><span class="hs-identifier hs-var hs-var">bind_nms</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(GenLocated SrcSpan Name -&gt; Name)
-&gt; [GenLocated SrcSpan Name] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name -&gt; Name
forall l e. GenLocated l e -&gt; e
</span><a href="GHC.Types.SrcLoc.html#unLoc"><span class="hs-identifier hs-var">unLoc</span></a></span><span> </span><span class="annot"><span class="annottext">([GenLocated SrcSpan Name] -&gt; [Name])
-&gt; [GenLocated SrcSpan Name] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed) -&gt; [Located (IdP (GhcPass 'Renamed))]
forall idL idR. LHsBindsLR idL idR -&gt; [Located (IdP idL)]
</span><a href="GHC.Hs.Utils.html#collectMethodBinders"><span class="hs-identifier hs-var">collectMethodBinders</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681162856"><span class="hs-identifier hs-var">binds</span></a></span><span>
</span><span id="line-1655"></span><span>        </span><span id="local-6989586621681162781"><span class="annot"><span class="annottext">cls_meth_nms :: [Name]
</span><a href="#local-6989586621681162781"><span class="hs-identifier hs-var hs-var">cls_meth_nms</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(ClassOpItem -&gt; Name) -&gt; [ClassOpItem] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">(Id -&gt; Name) -&gt; (ClassOpItem -&gt; Id) -&gt; ClassOpItem -&gt; Name
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">ClassOpItem -&gt; Id
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[ClassOpItem]
</span><a href="#local-6989586621681162857"><span class="hs-identifier hs-var">op_items</span></a></span><span>
</span><span id="line-1656"></span><span>        </span><span id="local-6989586621681162784"><span class="annot"><span class="annottext">mismatched_meths :: [Name]
</span><a href="#local-6989586621681162784"><span class="hs-identifier hs-var hs-var">mismatched_meths</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681162783"><span class="hs-identifier hs-var">bind_nms</span></a></span><span> </span><span class="annot"><span class="annottext">[Name] -&gt; [Name] -&gt; [Name]
forall a. Ord a =&gt; [a] -&gt; [a] -&gt; [a]
</span><a href="GHC.Data.List.SetOps.html#minusList"><span class="hs-operator hs-var">`minusList`</span></a></span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681162781"><span class="hs-identifier hs-var">cls_meth_nms</span></a></span><span>
</span><span id="line-1657"></span><span>
</span><span id="line-1658"></span><span class="hs-comment">{-
Note [Mismatched class methods and associated type families]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It's entirely possible for someone to put methods or associated type family
instances inside of a class in which it doesn't belong. For instance, we'd
want to fail if someone wrote this:

  instance Eq () where
    type Rep () = Maybe
    compare = undefined

Since neither the type family `Rep` nor the method `compare` belong to the
class `Eq`. Normally, this is caught in the renamer when resolving RdrNames,
since that would discover that the parent class `Eq` is incorrect.

However, there is a scenario in which the renamer could fail to catch this:
if the instance was generated through Template Haskell, as in #12387. In that
case, Template Haskell will provide fully resolved names (e.g.,
`GHC.Classes.compare`), so the renamer won't notice the sleight-of-hand going
on. For this reason, we also put an extra validity check for this in the
typechecker as a last resort.

Note [Avoid -Winaccessible-code when deriving]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Winaccessible-code can be particularly noisy when deriving instances for
GADTs. Consider the following example (adapted from #8128):

  data T a where
    MkT1 :: Int -&gt; T Int
    MkT2 :: T Bool
    MkT3 :: T Bool
  deriving instance Eq (T a)
  deriving instance Ord (T a)

In the derived Ord instance, GHC will generate the following code:

  instance Ord (T a) where
    compare x y
      = case x of
          MkT2
            -&gt; case y of
                 MkT1 {} -&gt; GT
                 MkT2    -&gt; EQ
                 _       -&gt; LT
          ...

However, that MkT1 is unreachable, since the type indices for MkT1 and MkT2
differ, so if -Winaccessible-code is enabled, then deriving this instance will
result in unwelcome warnings.

One conceivable approach to fixing this issue would be to change `deriving Ord`
such that it becomes smarter about not generating unreachable cases. This,
however, would be a highly nontrivial refactor, as we'd have to propagate
through typing information everywhere in the algorithm that generates Ord
instances in order to determine which cases were unreachable. This seems like
a lot of work for minimal gain, so we have opted not to go for this approach.

Instead, we take the much simpler approach of always disabling
-Winaccessible-code for derived code. To accomplish this, we do the following:

1. In tcMethods (which typechecks method bindings), disable
   -Winaccessible-code.
2. When creating Implications during typechecking, record this flag
   (in ic_warn_inaccessible) at the time of creation.
3. After typechecking comes error reporting, where GHC must decide how to
   report inaccessible code to the user, on an Implication-by-Implication
   basis. If an Implication's DynFlags indicate that -Winaccessible-code was
   disabled, then don't bother reporting it. That's it!
-}</span><span>
</span><span id="line-1727"></span><span>
</span><span id="line-1728"></span><span class="hs-comment">------------------------</span><span>
</span><span id="line-1729"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcMethodBody"><span class="hs-identifier hs-type">tcMethodBody</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1730"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Evidence.html#TcEvBinds"><span class="hs-identifier hs-type">TcEvBinds</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1731"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Class.html#HsSigFun"><span class="hs-identifier hs-type">HsSigFun</span></a></span><span>
</span><span id="line-1732"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Binds.html#LTcSpecPrag"><span class="hs-identifier hs-type">LTcSpecPrag</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Binds.html#LSig"><span class="hs-identifier hs-type">LSig</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1733"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBind"><span class="hs-identifier hs-type">LHsBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span>
</span><span id="line-1734"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBind"><span class="hs-identifier hs-type">LHsBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Constraint.html#Implication"><span class="hs-identifier hs-type">Implication</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1735"></span><span id="tcMethodBody"><span class="annot"><span class="annottext">tcMethodBody :: Class
-&gt; [Id]
-&gt; [Id]
-&gt; [PredType]
-&gt; TcEvBinds
-&gt; Bool
-&gt; HsSigFun
-&gt; [Located TcSpecPrag]
-&gt; [LSig (GhcPass 'Renamed)]
-&gt; Id
-&gt; GenLocated
     SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
-&gt; SrcSpan
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="GHC.Tc.TyCl.Instance.html#tcMethodBody"><span class="hs-identifier hs-var hs-var">tcMethodBody</span></a></span></span><span> </span><span id="local-6989586621681162778"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162778"><span class="hs-identifier hs-var">clas</span></a></span></span><span> </span><span id="local-6989586621681162777"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162777"><span class="hs-identifier hs-var">tyvars</span></a></span></span><span> </span><span id="local-6989586621681162776"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162776"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span></span><span> </span><span id="local-6989586621681162775"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162775"><span class="hs-identifier hs-var">inst_tys</span></a></span></span><span>
</span><span id="line-1736"></span><span>                     </span><span id="local-6989586621681162774"><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681162774"><span class="hs-identifier hs-var">dfun_ev_binds</span></a></span></span><span> </span><span id="local-6989586621681162773"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162773"><span class="hs-identifier hs-var">is_derived</span></a></span></span><span>
</span><span id="line-1737"></span><span>                     </span><span id="local-6989586621681162772"><span class="annot"><span class="annottext">HsSigFun
</span><a href="#local-6989586621681162772"><span class="hs-identifier hs-var">sig_fn</span></a></span></span><span> </span><span id="local-6989586621681162771"><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162771"><span class="hs-identifier hs-var">spec_inst_prags</span></a></span></span><span> </span><span id="local-6989586621681162770"><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162770"><span class="hs-identifier hs-var">prags</span></a></span></span><span>
</span><span id="line-1738"></span><span>                     </span><span id="local-6989586621681162769"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162769"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681162768"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162768"><span class="hs-identifier hs-var">bind_loc</span></a></span></span><span> </span><span id="local-6989586621681162767"><span class="annot"><span class="annottext">HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)
</span><a href="#local-6989586621681162767"><span class="hs-identifier hs-var">meth_bind</span></a></span></span><span class="hs-special">)</span><span> </span><span id="local-6989586621681162766"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162766"><span class="hs-identifier hs-var">bndr_loc</span></a></span></span><span>
</span><span id="line-1739"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOEnv
  (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="#local-6989586621681162765"><span class="hs-identifier hs-var">add_meth_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">(IOEnv
   (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
 -&gt; IOEnv
      (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication))
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1740"></span><span>    </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#traceTc"><span class="hs-identifier hs-var">traceTc</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcMethodBody&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162769"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162769"><span class="hs-identifier hs-var">sel_id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162766"><span class="hs-identifier hs-var">bndr_loc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1741"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162764"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162764"><span class="hs-identifier hs-var">global_meth_id</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162763"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162763"><span class="hs-identifier hs-var">local_meth_id</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TcM (Id, Id) -&gt; TcM (Id, Id)
forall a. SrcSpan -&gt; TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#setSrcSpan"><span class="hs-identifier hs-var">setSrcSpan</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162766"><span class="hs-identifier hs-var">bndr_loc</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM (Id, Id) -&gt; TcM (Id, Id)) -&gt; TcM (Id, Id) -&gt; TcM (Id, Id)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1742"></span><span>                                            </span><span class="annot"><span class="annottext">Class -&gt; [Id] -&gt; [Id] -&gt; [PredType] -&gt; Id -&gt; TcM (Id, Id)
</span><a href="GHC.Tc.TyCl.Instance.html#mkMethIds"><span class="hs-identifier hs-var">mkMethIds</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162778"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162777"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162776"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span>
</span><span id="line-1743"></span><span>                                                      </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162775"><span class="hs-identifier hs-var">inst_tys</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162769"><span class="hs-identifier hs-var">sel_id</span></a></span><span>
</span><span id="line-1744"></span><span>
</span><span id="line-1745"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162762"><span class="annot"><span class="annottext">lm_bind :: HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)
</span><a href="#local-6989586621681162762"><span class="hs-identifier hs-var hs-var">lm_bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)
</span><a href="#local-6989586621681162767"><span class="hs-identifier hs-var">meth_bind</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">fun_id :: Located (IdP (GhcPass 'Renamed))
</span><a href="GHC.Hs.Binds.html#fun_id"><span class="hs-identifier hs-var">fun_id</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; Name -&gt; GenLocated SrcSpan Name
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162766"><span class="hs-identifier hs-var">bndr_loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162763"><span class="hs-identifier hs-var">local_meth_id</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1746"></span><span>                       </span><span class="hs-comment">-- Substitute the local_meth_name for the binder</span><span>
</span><span id="line-1747"></span><span>                       </span><span class="hs-comment">-- NB: the binding is always a FunBind</span><span>
</span><span id="line-1748"></span><span>
</span><span id="line-1749"></span><span>            </span><span class="hs-comment">-- taking instance signature into account might change the type of</span><span>
</span><span id="line-1750"></span><span>            </span><span class="hs-comment">-- the local_meth_id</span><span>
</span><span id="line-1751"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162760"><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681162760"><span class="hs-identifier hs-var">meth_implic</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162759"><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681162759"><span class="hs-identifier hs-var">ev_binds_var</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162758"><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681162758"><span class="hs-identifier hs-var">tc_bind</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1752"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcM (LHsBinds GhcTc)
-&gt; TcM (Implication, EvBindsVar, LHsBinds GhcTc)
forall result. TcM result -&gt; TcM (Implication, EvBindsVar, result)
</span><a href="GHC.Tc.TyCl.Instance.html#checkInstConstraints"><span class="hs-identifier hs-var">checkInstConstraints</span></a></span><span> </span><span class="annot"><span class="annottext">(TcM (LHsBinds GhcTc)
 -&gt; TcM (Implication, EvBindsVar, LHsBinds GhcTc))
-&gt; TcM (LHsBinds GhcTc)
-&gt; TcM (Implication, EvBindsVar, LHsBinds GhcTc)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1753"></span><span>                </span><span class="annot"><span class="annottext">HsSigFun
-&gt; Id
-&gt; Id
-&gt; GenLocated
     SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
-&gt; TcM (LHsBinds GhcTc)
</span><a href="GHC.Tc.TyCl.Instance.html#tcMethodBodyHelp"><span class="hs-identifier hs-var">tcMethodBodyHelp</span></a></span><span> </span><span class="annot"><span class="annottext">HsSigFun
</span><a href="#local-6989586621681162772"><span class="hs-identifier hs-var">sig_fn</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162769"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162763"><span class="hs-identifier hs-var">local_meth_id</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SrcSpan
-&gt; HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)
-&gt; GenLocated
     SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162768"><span class="hs-identifier hs-var">bind_loc</span></a></span><span> </span><span class="annot"><span class="annottext">HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)
</span><a href="#local-6989586621681162762"><span class="hs-identifier hs-var">lm_bind</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1754"></span><span>
</span><span id="line-1755"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162756"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162756"><span class="hs-identifier hs-var">global_meth_id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [LSig (GhcPass 'Renamed)] -&gt; TcM Id
</span><a href="GHC.Tc.Gen.Sig.html#addInlinePrags"><span class="hs-identifier hs-var">addInlinePrags</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162764"><span class="hs-identifier hs-var">global_meth_id</span></a></span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162770"><span class="hs-identifier hs-var">prags</span></a></span><span>
</span><span id="line-1756"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162754"><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162754"><span class="hs-identifier hs-var">spec_prags</span></a></span></span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [LSig (GhcPass 'Renamed)] -&gt; TcM [Located TcSpecPrag]
</span><a href="GHC.Tc.Gen.Sig.html#tcSpecPrags"><span class="hs-identifier hs-var">tcSpecPrags</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162756"><span class="hs-identifier hs-var">global_meth_id</span></a></span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162770"><span class="hs-identifier hs-var">prags</span></a></span><span>
</span><span id="line-1757"></span><span>
</span><span id="line-1758"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162752"><span class="annot"><span class="annottext">specs :: TcSpecPrags
</span><a href="#local-6989586621681162752"><span class="hs-identifier hs-var hs-var">specs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; [Located TcSpecPrag] -&gt; [Located TcSpecPrag] -&gt; TcSpecPrags
</span><a href="GHC.Tc.TyCl.Instance.html#mk_meth_spec_prags"><span class="hs-identifier hs-var">mk_meth_spec_prags</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162756"><span class="hs-identifier hs-var">global_meth_id</span></a></span><span> </span><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162771"><span class="hs-identifier hs-var">spec_inst_prags</span></a></span><span> </span><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162754"><span class="hs-identifier hs-var">spec_prags</span></a></span><span>
</span><span id="line-1759"></span><span>              </span><span id="local-6989586621681162750"><span class="annot"><span class="annottext">export :: ABExport GhcTc
</span><a href="#local-6989586621681162750"><span class="hs-keyword hs-var hs-var">export</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ABE :: forall p.
XABE p -&gt; IdP p -&gt; IdP p -&gt; HsWrapper -&gt; TcSpecPrags -&gt; ABExport p
</span><a href="GHC.Hs.Binds.html#ABE"><span class="hs-identifier hs-type">ABE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">abe_ext :: XABE GhcTc
</span><a href="GHC.Hs.Binds.html#abe_ext"><span class="hs-identifier hs-var">abe_ext</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NoExtField
XABE GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span>
</span><span id="line-1760"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_poly :: IdP GhcTc
</span><a href="GHC.Hs.Binds.html#abe_poly"><span class="hs-identifier hs-var">abe_poly</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681162756"><span class="hs-identifier hs-var">global_meth_id</span></a></span><span>
</span><span id="line-1761"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_mono :: IdP GhcTc
</span><a href="GHC.Hs.Binds.html#abe_mono"><span class="hs-identifier hs-var">abe_mono</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681162763"><span class="hs-identifier hs-var">local_meth_id</span></a></span><span>
</span><span id="line-1762"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_wrap :: HsWrapper
</span><a href="GHC.Hs.Binds.html#abe_wrap"><span class="hs-identifier hs-var">abe_wrap</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="GHC.Tc.Types.Evidence.html#idHsWrapper"><span class="hs-identifier hs-var">idHsWrapper</span></a></span><span>
</span><span id="line-1763"></span><span>                           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_prags :: TcSpecPrags
</span><a href="GHC.Hs.Binds.html#abe_prags"><span class="hs-identifier hs-var">abe_prags</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcSpecPrags
</span><a href="#local-6989586621681162752"><span class="hs-identifier hs-var">specs</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1764"></span><span>
</span><span id="line-1765"></span><span>              </span><span id="local-6989586621681162749"><span class="annot"><span class="annottext">local_ev_binds :: TcEvBinds
</span><a href="#local-6989586621681162749"><span class="hs-identifier hs-var hs-var">local_ev_binds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">EvBindsVar -&gt; TcEvBinds
</span><a href="GHC.Tc.Types.Evidence.html#TcEvBinds"><span class="hs-identifier hs-var">TcEvBinds</span></a></span><span> </span><span class="annot"><span class="annottext">EvBindsVar
</span><a href="#local-6989586621681162759"><span class="hs-identifier hs-var">ev_binds_var</span></a></span><span>
</span><span id="line-1766"></span><span>              </span><span id="local-6989586621681162748"><span class="annot"><span class="annottext">full_bind :: HsBindLR GhcTc GhcTc
</span><a href="#local-6989586621681162748"><span class="hs-identifier hs-var hs-var">full_bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">AbsBinds :: forall idL idR.
XAbsBinds idL idR
-&gt; [Id]
-&gt; [Id]
-&gt; [ABExport idL]
-&gt; [TcEvBinds]
-&gt; LHsBinds idL
-&gt; Bool
-&gt; HsBindLR idL idR
</span><a href="GHC.Hs.Binds.html#AbsBinds"><span class="hs-identifier hs-type">AbsBinds</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">abs_ext :: XAbsBinds GhcTc GhcTc
</span><a href="GHC.Hs.Binds.html#abs_ext"><span class="hs-identifier hs-var">abs_ext</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NoExtField
XAbsBinds GhcTc GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span>
</span><span id="line-1767"></span><span>                                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_tvs :: [Id]
</span><a href="GHC.Hs.Binds.html#abs_tvs"><span class="hs-identifier hs-var">abs_tvs</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162777"><span class="hs-identifier hs-var">tyvars</span></a></span><span>
</span><span id="line-1768"></span><span>                                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_ev_vars :: [Id]
</span><a href="GHC.Hs.Binds.html#abs_ev_vars"><span class="hs-identifier hs-var">abs_ev_vars</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162776"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span>
</span><span id="line-1769"></span><span>                                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_exports :: [ABExport GhcTc]
</span><a href="GHC.Hs.Binds.html#abs_exports"><span class="hs-identifier hs-var">abs_exports</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">ABExport GhcTc
</span><a href="#local-6989586621681162750"><span class="hs-keyword hs-var">export</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1770"></span><span>                                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_ev_binds :: [TcEvBinds]
</span><a href="GHC.Hs.Binds.html#abs_ev_binds"><span class="hs-identifier hs-var">abs_ev_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681162774"><span class="hs-identifier hs-var">dfun_ev_binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TcEvBinds
</span><a href="#local-6989586621681162749"><span class="hs-identifier hs-var">local_ev_binds</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1771"></span><span>                                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_binds :: LHsBinds GhcTc
</span><a href="GHC.Hs.Binds.html#abs_binds"><span class="hs-identifier hs-var">abs_binds</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681162758"><span class="hs-identifier hs-var">tc_bind</span></a></span><span>
</span><span id="line-1772"></span><span>                                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_sig :: Bool
</span><a href="GHC.Hs.Binds.html#abs_sig"><span class="hs-identifier hs-var">abs_sig</span></a></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1773"></span><span>
</span><span id="line-1774"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Id, LHsBind GhcTc, Maybe Implication)
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162756"><span class="hs-identifier hs-var">global_meth_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; HsBindLR GhcTc GhcTc -&gt; LHsBind GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162768"><span class="hs-identifier hs-var">bind_loc</span></a></span><span> </span><span class="annot"><span class="annottext">HsBindLR GhcTc GhcTc
</span><a href="#local-6989586621681162748"><span class="hs-identifier hs-var">full_bind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Implication -&gt; Maybe Implication
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Implication
</span><a href="#local-6989586621681162760"><span class="hs-identifier hs-var">meth_implic</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1775"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1776"></span><span>        </span><span class="hs-comment">-- For instance decls that come from deriving clauses</span><span>
</span><span id="line-1777"></span><span>        </span><span class="hs-comment">-- we want to print out the full source code if there's an error</span><span>
</span><span id="line-1778"></span><span>        </span><span class="hs-comment">-- because otherwise the user won't see the code at all</span><span>
</span><span id="line-1779"></span><span>    </span><span id="local-6989586621681162765"><span class="annot"><span class="annottext">add_meth_ctxt :: IOEnv
  (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="#local-6989586621681162765"><span class="hs-identifier hs-var hs-var">add_meth_ctxt</span></a></span></span><span> </span><span id="local-6989586621681162747"><span class="annot"><span class="annottext">IOEnv
  (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="#local-6989586621681162747"><span class="hs-identifier hs-var">thing</span></a></span></span><span>
</span><span id="line-1780"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162773"><span class="hs-identifier hs-var">is_derived</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
-&gt; IOEnv
     (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
forall a. SDoc -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#addLandmarkErrCtxt"><span class="hs-identifier hs-var">addLandmarkErrCtxt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Class -&gt; [PredType] -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#derivBindCtxt"><span class="hs-identifier hs-var">derivBindCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162769"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162778"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162775"><span class="hs-identifier hs-var">inst_tys</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">IOEnv
  (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="#local-6989586621681162747"><span class="hs-identifier hs-var">thing</span></a></span><span>
</span><span id="line-1781"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IOEnv
  (Env TcGblEnv TcLclEnv) (Id, LHsBind GhcTc, Maybe Implication)
</span><a href="#local-6989586621681162747"><span class="hs-identifier hs-var">thing</span></a></span><span>
</span><span id="line-1782"></span><span>
</span><span id="line-1783"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcMethodBodyHelp"><span class="hs-identifier hs-type">tcMethodBodyHelp</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.TyCl.Class.html#HsSigFun"><span class="hs-identifier hs-type">HsSigFun</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span>
</span><span id="line-1784"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBind"><span class="hs-identifier hs-type">LHsBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1785"></span><span id="tcMethodBodyHelp"><span class="annot"><span class="annottext">tcMethodBodyHelp :: HsSigFun
-&gt; Id
-&gt; Id
-&gt; GenLocated
     SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
-&gt; TcM (LHsBinds GhcTc)
</span><a href="GHC.Tc.TyCl.Instance.html#tcMethodBodyHelp"><span class="hs-identifier hs-var hs-var">tcMethodBodyHelp</span></a></span></span><span> </span><span id="local-6989586621681162744"><span class="annot"><span class="annottext">HsSigFun
</span><a href="#local-6989586621681162744"><span class="hs-identifier hs-var">hs_sig_fn</span></a></span></span><span> </span><span id="local-6989586621681162743"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162743"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span> </span><span id="local-6989586621681162742"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162742"><span class="hs-identifier hs-var">local_meth_id</span></a></span></span><span> </span><span id="local-6989586621681162741"><span class="annot"><span class="annottext">GenLocated SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
</span><a href="#local-6989586621681162741"><span class="hs-identifier hs-var">meth_bind</span></a></span></span><span>
</span><span id="line-1786"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681162740"><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681162740"><span class="hs-identifier hs-var">hs_sig_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">HsSigFun
</span><a href="#local-6989586621681162744"><span class="hs-identifier hs-var">hs_sig_fn</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162739"><span class="hs-identifier hs-var">sel_name</span></a></span><span>
</span><span id="line-1787"></span><span>              </span><span class="hs-comment">-- There is a signature in the instance</span><span>
</span><span id="line-1788"></span><span>              </span><span class="hs-comment">-- See Note [Instance method signatures]</span><span>
</span><span id="line-1789"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162738"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162738"><span class="hs-identifier hs-var">sig_ty</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162737"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162737"><span class="hs-identifier hs-var">hs_wrap</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-1790"></span><span>             </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TcRn (PredType, HsWrapper) -&gt; TcRn (PredType, HsWrapper)
forall a. SrcSpan -&gt; TcRn a -&gt; TcRn a
</span><a href="GHC.Tc.Utils.Monad.html#setSrcSpan"><span class="hs-identifier hs-var">setSrcSpan</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsType (GhcPass 'Renamed) -&gt; SrcSpan
forall l e. GenLocated l e -&gt; l
</span><a href="GHC.Types.SrcLoc.html#getLoc"><span class="hs-identifier hs-var">getLoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed) -&gt; LHsType (GhcPass 'Renamed)
forall (p :: Pass). LHsSigType (GhcPass p) -&gt; LHsType (GhcPass p)
</span><a href="GHC.Hs.Type.html#hsSigType"><span class="hs-identifier hs-var">hsSigType</span></a></span><span> </span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681162740"><span class="hs-identifier hs-var">hs_sig_ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcRn (PredType, HsWrapper) -&gt; TcRn (PredType, HsWrapper))
-&gt; TcRn (PredType, HsWrapper) -&gt; TcRn (PredType, HsWrapper)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1791"></span><span>                </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681162736"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162736"><span class="hs-identifier hs-var">inst_sigs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; TcRn Bool
forall gbl lcl. Extension -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#xoptM"><span class="hs-identifier hs-var">xoptM</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#InstanceSigs"><span class="hs-identifier hs-var">LangExt.InstanceSigs</span></a></span><span>
</span><span id="line-1792"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#checkTc"><span class="hs-identifier hs-var">checkTc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162736"><span class="hs-identifier hs-var">inst_sigs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; LHsSigType (GhcPass 'Renamed) -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#misplacedInstSig"><span class="hs-identifier hs-var">misplacedInstSig</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162739"><span class="hs-identifier hs-var">sel_name</span></a></span><span> </span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681162740"><span class="hs-identifier hs-var">hs_sig_ty</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1793"></span><span>                   </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162733"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162733"><span class="hs-identifier hs-var">sig_ty</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; LHsSigType (GhcPass 'Renamed) -&gt; TcM PredType
</span><a href="GHC.Tc.Gen.HsType.html#tcHsSigType"><span class="hs-identifier hs-var">tcHsSigType</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; Bool -&gt; UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#FunSigCtxt"><span class="hs-identifier hs-var">FunSigCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162739"><span class="hs-identifier hs-var">sel_name</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681162740"><span class="hs-identifier hs-var">hs_sig_ty</span></a></span><span>
</span><span id="line-1794"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162730"><span class="annot"><span class="annottext">local_meth_ty :: PredType
</span><a href="#local-6989586621681162730"><span class="hs-identifier hs-var hs-var">local_meth_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162742"><span class="hs-identifier hs-var">local_meth_id</span></a></span><span>
</span><span id="line-1795"></span><span>                         </span><span id="local-6989586621681162729"><span class="annot"><span class="annottext">ctxt :: UserTypeCtxt
</span><a href="#local-6989586621681162729"><span class="hs-identifier hs-var hs-var">ctxt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool -&gt; UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#FunSigCtxt"><span class="hs-identifier hs-var">FunSigCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162739"><span class="hs-identifier hs-var">sel_name</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1796"></span><span>                                </span><span class="hs-comment">-- False &lt;=&gt; do not report redundant constraints when</span><span>
</span><span id="line-1797"></span><span>                                </span><span class="hs-comment">--           checking instance-sig &lt;= class-meth-sig</span><span>
</span><span id="line-1798"></span><span>                                </span><span class="hs-comment">-- The instance-sig is the focus here; the class-meth-sig</span><span>
</span><span id="line-1799"></span><span>                                </span><span class="hs-comment">-- is fixed (#18036)</span><span>
</span><span id="line-1800"></span><span>                   </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162728"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162728"><span class="hs-identifier hs-var">hs_wrap</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(TidyEnv -&gt; TcM (TidyEnv, SDoc)) -&gt; TcM HsWrapper -&gt; TcM HsWrapper
forall a. (TidyEnv -&gt; TcM (TidyEnv, SDoc)) -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#addErrCtxtM"><span class="hs-identifier hs-var">addErrCtxtM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; PredType -&gt; PredType -&gt; TidyEnv -&gt; TcM (TidyEnv, SDoc)
</span><a href="GHC.Tc.TyCl.Instance.html#methSigCtxt"><span class="hs-identifier hs-var">methSigCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162739"><span class="hs-identifier hs-var">sel_name</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162733"><span class="hs-identifier hs-var">sig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162730"><span class="hs-identifier hs-var">local_meth_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcM HsWrapper -&gt; TcM HsWrapper) -&gt; TcM HsWrapper -&gt; TcM HsWrapper
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1801"></span><span>                                </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; PredType -&gt; PredType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Utils.Unify.html#tcSubTypeSigma"><span class="hs-identifier hs-var">tcSubTypeSigma</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681162729"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162733"><span class="hs-identifier hs-var">sig_ty</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162730"><span class="hs-identifier hs-var">local_meth_ty</span></a></span><span>
</span><span id="line-1802"></span><span>                   </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(PredType, HsWrapper) -&gt; TcRn (PredType, HsWrapper)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162733"><span class="hs-identifier hs-var">sig_ty</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162728"><span class="hs-identifier hs-var">hs_wrap</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1803"></span><span>
</span><span id="line-1804"></span><span>       </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162724"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162724"><span class="hs-identifier hs-var">inner_meth_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Monad.html#newName"><span class="hs-identifier hs-var">newName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162739"><span class="hs-identifier hs-var">sel_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1805"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162722"><span class="annot"><span class="annottext">ctxt :: UserTypeCtxt
</span><a href="#local-6989586621681162722"><span class="hs-identifier hs-var hs-var">ctxt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool -&gt; UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#FunSigCtxt"><span class="hs-identifier hs-var">FunSigCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162739"><span class="hs-identifier hs-var">sel_name</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-1806"></span><span>                    </span><span class="hs-comment">-- True &lt;=&gt; check for redundant constraints in the</span><span>
</span><span id="line-1807"></span><span>                    </span><span class="hs-comment">--          user-specified instance signature</span><span>
</span><span id="line-1808"></span><span>             </span><span id="local-6989586621681162721"><span class="annot"><span class="annottext">inner_meth_id :: Id
</span><a href="#local-6989586621681162721"><span class="hs-identifier hs-var hs-var">inner_meth_id</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Name -&gt; PredType -&gt; PredType -&gt; Id
Name -&gt; PredType -&gt; PredType -&gt; Id
</span><a href="GHC.Types.Id.html#mkLocalId"><span class="hs-identifier hs-var">mkLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162724"><span class="hs-identifier hs-var">inner_meth_name</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162738"><span class="hs-identifier hs-var">sig_ty</span></a></span><span>
</span><span id="line-1809"></span><span>             </span><span id="local-6989586621681162720"><span class="annot"><span class="annottext">inner_meth_sig :: TcIdSigInfo
</span><a href="#local-6989586621681162720"><span class="hs-identifier hs-var hs-var">inner_meth_sig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CompleteSig :: Id -&gt; UserTypeCtxt -&gt; SrcSpan -&gt; TcIdSigInfo
</span><a href="GHC.Tc.Types.html#CompleteSig"><span class="hs-identifier hs-type">CompleteSig</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">sig_bndr :: Id
</span><a href="GHC.Tc.Types.html#sig_bndr"><span class="hs-identifier hs-var">sig_bndr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162721"><span class="hs-identifier hs-var">inner_meth_id</span></a></span><span>
</span><span id="line-1810"></span><span>                                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sig_ctxt :: UserTypeCtxt
</span><a href="GHC.Tc.Types.html#sig_ctxt"><span class="hs-identifier hs-var">sig_ctxt</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681162722"><span class="hs-identifier hs-var">ctxt</span></a></span><span>
</span><span id="line-1811"></span><span>                                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">sig_loc :: SrcSpan
</span><a href="GHC.Tc.Types.html#sig_loc"><span class="hs-identifier hs-var">sig_loc</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LHsType (GhcPass 'Renamed) -&gt; SrcSpan
forall l e. GenLocated l e -&gt; l
</span><a href="GHC.Types.SrcLoc.html#getLoc"><span class="hs-identifier hs-var">getLoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed) -&gt; LHsType (GhcPass 'Renamed)
forall (p :: Pass). LHsSigType (GhcPass p) -&gt; LHsType (GhcPass p)
</span><a href="GHC.Hs.Type.html#hsSigType"><span class="hs-identifier hs-var">hsSigType</span></a></span><span> </span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681162740"><span class="hs-identifier hs-var">hs_sig_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1812"></span><span>
</span><span id="line-1813"></span><span>
</span><span id="line-1814"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162715"><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681162715"><span class="hs-identifier hs-var">tc_bind</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span id="local-6989586621681162714"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162714"><span class="hs-identifier hs-var">inner_id</span></a></span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcPragEnv
-&gt; TcIdSigInfo
-&gt; GenLocated
     SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
-&gt; TcM (LHsBinds GhcTc, [Id])
</span><a href="GHC.Tc.Gen.Bind.html#tcPolyCheck"><span class="hs-identifier hs-var">tcPolyCheck</span></a></span><span> </span><span class="annot"><span class="annottext">TcPragEnv
</span><a href="#local-6989586621681162712"><span class="hs-identifier hs-var">no_prag_fn</span></a></span><span> </span><span class="annot"><span class="annottext">TcIdSigInfo
</span><a href="#local-6989586621681162720"><span class="hs-identifier hs-var">inner_meth_sig</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
</span><a href="#local-6989586621681162741"><span class="hs-identifier hs-var">meth_bind</span></a></span><span>
</span><span id="line-1815"></span><span>
</span><span id="line-1816"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162711"><span class="annot"><span class="annottext">export :: ABExport GhcTc
</span><a href="#local-6989586621681162711"><span class="hs-keyword hs-var hs-var">export</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ABE :: forall p.
XABE p -&gt; IdP p -&gt; IdP p -&gt; HsWrapper -&gt; TcSpecPrags -&gt; ABExport p
</span><a href="GHC.Hs.Binds.html#ABE"><span class="hs-identifier hs-type">ABE</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">abe_ext :: XABE GhcTc
</span><a href="GHC.Hs.Binds.html#abe_ext"><span class="hs-identifier hs-var">abe_ext</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NoExtField
XABE GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span>
</span><span id="line-1817"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_poly :: IdP GhcTc
</span><a href="GHC.Hs.Binds.html#abe_poly"><span class="hs-identifier hs-var">abe_poly</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681162742"><span class="hs-identifier hs-var">local_meth_id</span></a></span><span>
</span><span id="line-1818"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_mono :: IdP GhcTc
</span><a href="GHC.Hs.Binds.html#abe_mono"><span class="hs-identifier hs-var">abe_mono</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id
IdP GhcTc
</span><a href="#local-6989586621681162714"><span class="hs-identifier hs-var">inner_id</span></a></span><span>
</span><span id="line-1819"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_wrap :: HsWrapper
</span><a href="GHC.Hs.Binds.html#abe_wrap"><span class="hs-identifier hs-var">abe_wrap</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162737"><span class="hs-identifier hs-var">hs_wrap</span></a></span><span>
</span><span id="line-1820"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abe_prags :: TcSpecPrags
</span><a href="GHC.Hs.Binds.html#abe_prags"><span class="hs-identifier hs-var">abe_prags</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcSpecPrags
</span><a href="GHC.Hs.Binds.html#noSpecPrags"><span class="hs-identifier hs-var">noSpecPrags</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1821"></span><span>
</span><span id="line-1822"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc -&gt; TcM (LHsBinds GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsBind GhcTc -&gt; LHsBinds GhcTc
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="annot"><span class="annottext">(LHsBind GhcTc -&gt; LHsBinds GhcTc)
-&gt; LHsBind GhcTc -&gt; LHsBinds GhcTc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; HsBindLR GhcTc GhcTc -&gt; LHsBind GhcTc
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenLocated SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
-&gt; SrcSpan
forall l e. GenLocated l e -&gt; l
</span><a href="GHC.Types.SrcLoc.html#getLoc"><span class="hs-identifier hs-var">getLoc</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
</span><a href="#local-6989586621681162741"><span class="hs-identifier hs-var">meth_bind</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(HsBindLR GhcTc GhcTc -&gt; LHsBind GhcTc)
-&gt; HsBindLR GhcTc GhcTc -&gt; LHsBind GhcTc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1823"></span><span>                 </span><span class="annot"><span class="annottext">AbsBinds :: forall idL idR.
XAbsBinds idL idR
-&gt; [Id]
-&gt; [Id]
-&gt; [ABExport idL]
-&gt; [TcEvBinds]
-&gt; LHsBinds idL
-&gt; Bool
-&gt; HsBindLR idL idR
</span><a href="GHC.Hs.Binds.html#AbsBinds"><span class="hs-identifier hs-type">AbsBinds</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">abs_ext :: XAbsBinds GhcTc GhcTc
</span><a href="GHC.Hs.Binds.html#abs_ext"><span class="hs-identifier hs-var">abs_ext</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NoExtField
XAbsBinds GhcTc GhcTc
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_tvs :: [Id]
</span><a href="GHC.Hs.Binds.html#abs_tvs"><span class="hs-identifier hs-var">abs_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_ev_vars :: [Id]
</span><a href="GHC.Hs.Binds.html#abs_ev_vars"><span class="hs-identifier hs-var">abs_ev_vars</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1824"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_exports :: [ABExport GhcTc]
</span><a href="GHC.Hs.Binds.html#abs_exports"><span class="hs-identifier hs-var">abs_exports</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">ABExport GhcTc
</span><a href="#local-6989586621681162711"><span class="hs-keyword hs-var">export</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1825"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_binds :: LHsBinds GhcTc
</span><a href="GHC.Hs.Binds.html#abs_binds"><span class="hs-identifier hs-var">abs_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681162715"><span class="hs-identifier hs-var">tc_bind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_ev_binds :: [TcEvBinds]
</span><a href="GHC.Hs.Binds.html#abs_ev_binds"><span class="hs-identifier hs-var">abs_ev_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1826"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">abs_sig :: Bool
</span><a href="GHC.Hs.Binds.html#abs_sig"><span class="hs-identifier hs-var">abs_sig</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1827"></span><span>
</span><span id="line-1828"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>  </span><span class="hs-comment">-- No instance signature</span><span>
</span><span id="line-1829"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162710"><span class="annot"><span class="annottext">ctxt :: UserTypeCtxt
</span><a href="#local-6989586621681162710"><span class="hs-identifier hs-var hs-var">ctxt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; Bool -&gt; UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#FunSigCtxt"><span class="hs-identifier hs-var">FunSigCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162739"><span class="hs-identifier hs-var">sel_name</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-1830"></span><span>                    </span><span class="hs-comment">-- False &lt;=&gt; don't report redundant constraints</span><span>
</span><span id="line-1831"></span><span>                    </span><span class="hs-comment">-- The signature is not under the users control!</span><span>
</span><span id="line-1832"></span><span>             </span><span id="local-6989586621681162709"><span class="annot"><span class="annottext">tc_sig :: TcIdSigInfo
</span><a href="#local-6989586621681162709"><span class="hs-identifier hs-var hs-var">tc_sig</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; Id -&gt; TcIdSigInfo
</span><a href="GHC.Tc.Gen.Sig.html#completeSigFromId"><span class="hs-identifier hs-var">completeSigFromId</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="#local-6989586621681162710"><span class="hs-identifier hs-var">ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162742"><span class="hs-identifier hs-var">local_meth_id</span></a></span><span>
</span><span id="line-1833"></span><span>              </span><span class="hs-comment">-- Absent a type sig, there are no new scoped type variables here</span><span>
</span><span id="line-1834"></span><span>              </span><span class="hs-comment">-- Only the ones from the instance decl itself, which are already</span><span>
</span><span id="line-1835"></span><span>              </span><span class="hs-comment">-- in scope.  Example:</span><span>
</span><span id="line-1836"></span><span>              </span><span class="hs-comment">--      class C a where { op :: forall b. Eq b =&gt; ... }</span><span>
</span><span id="line-1837"></span><span>              </span><span class="hs-comment">--      instance C [c] where { op = &lt;rhs&gt; }</span><span>
</span><span id="line-1838"></span><span>              </span><span class="hs-comment">-- In &lt;rhs&gt;, 'c' is scope but 'b' is not!</span><span>
</span><span id="line-1839"></span><span>
</span><span id="line-1840"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162707"><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681162707"><span class="hs-identifier hs-var">tc_bind</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcPragEnv
-&gt; TcIdSigInfo
-&gt; GenLocated
     SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
-&gt; TcM (LHsBinds GhcTc, [Id])
</span><a href="GHC.Tc.Gen.Bind.html#tcPolyCheck"><span class="hs-identifier hs-var">tcPolyCheck</span></a></span><span> </span><span class="annot"><span class="annottext">TcPragEnv
</span><a href="#local-6989586621681162712"><span class="hs-identifier hs-var">no_prag_fn</span></a></span><span> </span><span class="annot"><span class="annottext">TcIdSigInfo
</span><a href="#local-6989586621681162709"><span class="hs-identifier hs-var">tc_sig</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
</span><a href="#local-6989586621681162741"><span class="hs-identifier hs-var">meth_bind</span></a></span><span>
</span><span id="line-1841"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc -&gt; TcM (LHsBinds GhcTc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds GhcTc
</span><a href="#local-6989586621681162707"><span class="hs-identifier hs-var">tc_bind</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1842"></span><span>
</span><span id="line-1843"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1844"></span><span>    </span><span id="local-6989586621681162739"><span class="annot"><span class="annottext">sel_name :: Name
</span><a href="#local-6989586621681162739"><span class="hs-identifier hs-var hs-var">sel_name</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162743"><span class="hs-identifier hs-var">sel_id</span></a></span><span>
</span><span id="line-1845"></span><span>    </span><span id="local-6989586621681162712"><span class="annot"><span class="annottext">no_prag_fn :: TcPragEnv
</span><a href="#local-6989586621681162712"><span class="hs-identifier hs-var hs-var">no_prag_fn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcPragEnv
</span><a href="GHC.Tc.Gen.Sig.html#emptyPragEnv"><span class="hs-identifier hs-var">emptyPragEnv</span></a></span><span>   </span><span class="hs-comment">-- No pragmas for local_meth_id;</span><span>
</span><span id="line-1846"></span><span>                                </span><span class="hs-comment">-- they are all for meth_id</span><span>
</span><span id="line-1847"></span><span>
</span><span id="line-1848"></span><span>
</span><span id="line-1849"></span><span class="hs-comment">------------------------</span><span>
</span><span id="line-1850"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#mkMethIds"><span class="hs-identifier hs-type">mkMethIds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TcTyVar"><span class="hs-identifier hs-type">TcTyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#EvVar"><span class="hs-identifier hs-type">EvVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1851"></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcId"><span class="hs-identifier hs-type">TcId</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1852"></span><span>             </span><span class="hs-comment">-- returns (poly_id, local_id), but ignoring any instance signature</span><span>
</span><span id="line-1853"></span><span>             </span><span class="hs-comment">-- See Note [Instance method signatures]</span><span>
</span><span id="line-1854"></span><span id="mkMethIds"><span class="annot"><span class="annottext">mkMethIds :: Class -&gt; [Id] -&gt; [Id] -&gt; [PredType] -&gt; Id -&gt; TcM (Id, Id)
</span><a href="GHC.Tc.TyCl.Instance.html#mkMethIds"><span class="hs-identifier hs-var hs-var">mkMethIds</span></a></span></span><span> </span><span id="local-6989586621681162705"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162705"><span class="hs-identifier hs-var">clas</span></a></span></span><span> </span><span id="local-6989586621681162704"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162704"><span class="hs-identifier hs-var">tyvars</span></a></span></span><span> </span><span id="local-6989586621681162703"><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162703"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span></span><span> </span><span id="local-6989586621681162702"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162702"><span class="hs-identifier hs-var">inst_tys</span></a></span></span><span> </span><span id="local-6989586621681162701"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162701"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span>
</span><span id="line-1855"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681162700"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162700"><span class="hs-identifier hs-var">poly_meth_name</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Monad.html#newName"><span class="hs-identifier hs-var">newName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OccName -&gt; OccName
</span><a href="GHC.Types.Name.Occurrence.html#mkClassOpAuxOcc"><span class="hs-identifier hs-var">mkClassOpAuxOcc</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681162698"><span class="hs-identifier hs-var">sel_occ</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1856"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162697"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162697"><span class="hs-identifier hs-var">local_meth_name</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">OccName -&gt; TcM Name
</span><a href="GHC.Tc.Utils.Monad.html#newName"><span class="hs-identifier hs-var">newName</span></a></span><span> </span><span class="annot"><span class="annottext">OccName
</span><a href="#local-6989586621681162698"><span class="hs-identifier hs-var">sel_occ</span></a></span><span>
</span><span id="line-1857"></span><span>                  </span><span class="hs-comment">-- Base the local_meth_name on the selector name, because</span><span>
</span><span id="line-1858"></span><span>                  </span><span class="hs-comment">-- type errors from tcMethodBody come from here</span><span>
</span><span id="line-1859"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162696"><span class="annot"><span class="annottext">poly_meth_id :: Id
</span><a href="#local-6989586621681162696"><span class="hs-identifier hs-var hs-var">poly_meth_id</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Name -&gt; PredType -&gt; PredType -&gt; Id
Name -&gt; PredType -&gt; PredType -&gt; Id
</span><a href="GHC.Types.Id.html#mkLocalId"><span class="hs-identifier hs-var">mkLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162700"><span class="hs-identifier hs-var">poly_meth_name</span></a></span><span>  </span><span class="annot"><span class="annottext">PredType
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162695"><span class="hs-identifier hs-var">poly_meth_ty</span></a></span><span>
</span><span id="line-1860"></span><span>              </span><span id="local-6989586621681162694"><span class="annot"><span class="annottext">local_meth_id :: Id
</span><a href="#local-6989586621681162694"><span class="hs-identifier hs-var hs-var">local_meth_id</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Name -&gt; PredType -&gt; PredType -&gt; Id
Name -&gt; PredType -&gt; PredType -&gt; Id
</span><a href="GHC.Types.Id.html#mkLocalId"><span class="hs-identifier hs-var">mkLocalId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162697"><span class="hs-identifier hs-var">local_meth_name</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="GHC.Core.Type.html#Many"><span class="hs-identifier hs-var">Many</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162693"><span class="hs-identifier hs-var">local_meth_ty</span></a></span><span>
</span><span id="line-1861"></span><span>
</span><span id="line-1862"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Id, Id) -&gt; TcM (Id, Id)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162696"><span class="hs-identifier hs-var">poly_meth_id</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162694"><span class="hs-identifier hs-var">local_meth_id</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1863"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1864"></span><span>    </span><span id="local-6989586621681162692"><span class="annot"><span class="annottext">sel_name :: Name
</span><a href="#local-6989586621681162692"><span class="hs-identifier hs-var hs-var">sel_name</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162701"><span class="hs-identifier hs-var">sel_id</span></a></span><span>
</span><span id="line-1865"></span><span>    </span><span class="hs-comment">-- Force so that a thunk doesn't end up in a Name (#19619)</span><span>
</span><span id="line-1866"></span><span>    </span><span class="hs-glyph">!</span><span id="local-6989586621681162698"><span class="annot"><span class="annottext">sel_occ :: OccName
</span><a href="#local-6989586621681162698"><span class="hs-identifier hs-var hs-var">sel_occ</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162692"><span class="hs-identifier hs-var">sel_name</span></a></span><span>
</span><span id="line-1867"></span><span>    </span><span id="local-6989586621681162693"><span class="annot"><span class="annottext">local_meth_ty :: PredType
</span><a href="#local-6989586621681162693"><span class="hs-identifier hs-var hs-var">local_meth_ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; Id -&gt; [PredType] -&gt; PredType
</span><a href="GHC.Tc.TyCl.Class.html#instantiateMethod"><span class="hs-identifier hs-var">instantiateMethod</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162705"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162701"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162702"><span class="hs-identifier hs-var">inst_tys</span></a></span><span>
</span><span id="line-1868"></span><span>    </span><span id="local-6989586621681162695"><span class="annot"><span class="annottext">poly_meth_ty :: PredType
</span><a href="#local-6989586621681162695"><span class="hs-identifier hs-var hs-var">poly_meth_ty</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Id] -&gt; [PredType] -&gt; PredType -&gt; PredType
</span><a href="GHC.Tc.Utils.TcType.html#mkSpecSigmaTy"><span class="hs-identifier hs-var">mkSpecSigmaTy</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162704"><span class="hs-identifier hs-var">tyvars</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162690"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162693"><span class="hs-identifier hs-var">local_meth_ty</span></a></span><span>
</span><span id="line-1869"></span><span>    </span><span id="local-6989586621681162690"><span class="annot"><span class="annottext">theta :: [PredType]
</span><a href="#local-6989586621681162690"><span class="hs-identifier hs-var hs-var">theta</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Id -&gt; PredType) -&gt; [Id] -&gt; [PredType]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">[Id]
</span><a href="#local-6989586621681162703"><span class="hs-identifier hs-var">dfun_ev_vars</span></a></span><span>
</span><span id="line-1870"></span><span>
</span><span id="line-1871"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#methSigCtxt"><span class="hs-identifier hs-type">methSigCtxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Var.Env.html#TidyEnv"><span class="hs-identifier hs-type">TidyEnv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#MsgDoc"><span class="hs-identifier hs-type">MsgDoc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1872"></span><span id="methSigCtxt"><span class="annot"><span class="annottext">methSigCtxt :: Name -&gt; PredType -&gt; PredType -&gt; TidyEnv -&gt; TcM (TidyEnv, SDoc)
</span><a href="GHC.Tc.TyCl.Instance.html#methSigCtxt"><span class="hs-identifier hs-var hs-var">methSigCtxt</span></a></span></span><span> </span><span id="local-6989586621681162688"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162688"><span class="hs-identifier hs-var">sel_name</span></a></span></span><span> </span><span id="local-6989586621681162687"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162687"><span class="hs-identifier hs-var">sig_ty</span></a></span></span><span> </span><span id="local-6989586621681162686"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162686"><span class="hs-identifier hs-var">meth_ty</span></a></span></span><span> </span><span id="local-6989586621681162685"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681162685"><span class="hs-identifier hs-var">env0</span></a></span></span><span>
</span><span id="line-1873"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162684"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681162684"><span class="hs-identifier hs-var">env1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162683"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162683"><span class="hs-identifier hs-var">sig_ty</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; PredType -&gt; TcM (TidyEnv, PredType)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681162685"><span class="hs-identifier hs-var">env0</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162687"><span class="hs-identifier hs-var">sig_ty</span></a></span><span>
</span><span id="line-1874"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162681"><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681162681"><span class="hs-identifier hs-var">env2</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162680"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162680"><span class="hs-identifier hs-var">meth_ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TidyEnv -&gt; PredType -&gt; TcM (TidyEnv, PredType)
</span><a href="GHC.Tc.Utils.TcMType.html#zonkTidyTcType"><span class="hs-identifier hs-var">zonkTidyTcType</span></a></span><span> </span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681162684"><span class="hs-identifier hs-var">env1</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162686"><span class="hs-identifier hs-var">meth_ty</span></a></span><span>
</span><span id="line-1875"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162679"><span class="annot"><span class="annottext">msg :: SDoc
</span><a href="#local-6989586621681162679"><span class="hs-identifier hs-var hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; ConTag -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;When checking that instance signature for&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162688"><span class="hs-identifier hs-var">sel_name</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1876"></span><span>                      </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is more general than its signature in the class&quot;</span></span><span>
</span><span id="line-1877"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Instance sig:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162683"><span class="hs-identifier hs-var">sig_ty</span></a></span><span>
</span><span id="line-1878"></span><span>                              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;   Class sig:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162680"><span class="hs-identifier hs-var">meth_ty</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1879"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(TidyEnv, SDoc) -&gt; TcM (TidyEnv, SDoc)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TidyEnv
</span><a href="#local-6989586621681162681"><span class="hs-identifier hs-var">env2</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681162679"><span class="hs-identifier hs-var">msg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1880"></span><span>
</span><span id="line-1881"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#misplacedInstSig"><span class="hs-identifier hs-type">misplacedInstSig</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Type.html#LHsSigType"><span class="hs-identifier hs-type">LHsSigType</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-1882"></span><span id="misplacedInstSig"><span class="annot"><span class="annottext">misplacedInstSig :: Name -&gt; LHsSigType (GhcPass 'Renamed) -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#misplacedInstSig"><span class="hs-identifier hs-var hs-var">misplacedInstSig</span></a></span></span><span> </span><span id="local-6989586621681162676"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162676"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621681162675"><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681162675"><span class="hs-identifier hs-var">hs_ty</span></a></span></span><span>
</span><span id="line-1883"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; ConTag -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Illegal type signature in instance declaration:&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-1884"></span><span>              </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; ConTag -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Name -&gt; SDoc
forall a. NamedThing a =&gt; a -&gt; SDoc
</span><a href="GHC.Types.Name.html#pprPrefixName"><span class="hs-identifier hs-var">pprPrefixName</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162676"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1885"></span><span>                    </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#dcolon"><span class="hs-identifier hs-var">dcolon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681162675"><span class="hs-identifier hs-var">hs_ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1886"></span><span>         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;(Use InstanceSigs to allow this)&quot;</span></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1887"></span><span>
</span><span id="line-1888"></span><span class="hs-comment">{- Note [Instance method signatures]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
With -XInstanceSigs we allow the user to supply a signature for the
method in an instance declaration.  Here is an artificial example:

       data T a = MkT a
       instance Ord a =&gt; Ord (T a) where
         (&gt;) :: forall b. b -&gt; b -&gt; Bool
         (&gt;) = error &quot;You can't compare Ts&quot;

The instance signature can be *more* polymorphic than the instantiated
class method (in this case: Age -&gt; Age -&gt; Bool), but it cannot be less
polymorphic.  Moreover, if a signature is given, the implementation
code should match the signature, and type variables bound in the
singature should scope over the method body.

We achieve this by building a TcSigInfo for the method, whether or not
there is an instance method signature, and using that to typecheck
the declaration (in tcMethodBody).  That means, conveniently,
that the type variables bound in the signature will scope over the body.

What about the check that the instance method signature is more
polymorphic than the instantiated class method type?  We just do a
tcSubType call in tcMethodBodyHelp, and generate a nested AbsBind, like
this (for the example above

 AbsBind { abs_tvs = [a], abs_ev_vars = [d:Ord a]
         , abs_exports
             = ABExport { (&gt;) :: forall a. Ord a =&gt; T a -&gt; T a -&gt; Bool
                        , gr_lcl :: T a -&gt; T a -&gt; Bool }
         , abs_binds
             = AbsBind { abs_tvs = [], abs_ev_vars = []
                       , abs_exports = ABExport { gr_lcl :: T a -&gt; T a -&gt; Bool
                                                , gr_inner :: forall b. b -&gt; b -&gt; Bool }
                       , abs_binds = AbsBind { abs_tvs = [b], abs_ev_vars = []
                                             , ..etc.. }
               } }

Wow!  Three nested AbsBinds!
 * The outer one abstracts over the tyvars and dicts for the instance
 * The middle one is only present if there is an instance signature,
   and does the impedance matching for that signature
 * The inner one is for the method binding itself against either the
   signature from the class, or the instance signature.
-}</span><span>
</span><span id="line-1933"></span><span>
</span><span id="line-1934"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-1935"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#mk_meth_spec_prags"><span class="hs-identifier hs-type">mk_meth_spec_prags</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Binds.html#LTcSpecPrag"><span class="hs-identifier hs-type">LTcSpecPrag</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Binds.html#LTcSpecPrag"><span class="hs-identifier hs-type">LTcSpecPrag</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#TcSpecPrags"><span class="hs-identifier hs-type">TcSpecPrags</span></a></span><span>
</span><span id="line-1936"></span><span>        </span><span class="hs-comment">-- Adapt the 'SPECIALISE instance' pragmas to work for this method Id</span><span>
</span><span id="line-1937"></span><span>        </span><span class="hs-comment">-- There are two sources:</span><span>
</span><span id="line-1938"></span><span>        </span><span class="hs-comment">--   * spec_prags_for_me: {-# SPECIALISE op :: &lt;blah&gt; #-}</span><span>
</span><span id="line-1939"></span><span>        </span><span class="hs-comment">--   * spec_prags_from_inst: derived from {-# SPECIALISE instance :: &lt;blah&gt; #-}</span><span>
</span><span id="line-1940"></span><span>        </span><span class="hs-comment">--     These ones have the dfun inside, but [perhaps surprisingly]</span><span>
</span><span id="line-1941"></span><span>        </span><span class="hs-comment">--     the correct wrapper.</span><span>
</span><span id="line-1942"></span><span>        </span><span class="hs-comment">-- See Note [Handling SPECIALISE pragmas] in GHC.Tc.Gen.Bind</span><span>
</span><span id="line-1943"></span><span id="mk_meth_spec_prags"><span class="annot"><span class="annottext">mk_meth_spec_prags :: Id -&gt; [Located TcSpecPrag] -&gt; [Located TcSpecPrag] -&gt; TcSpecPrags
</span><a href="GHC.Tc.TyCl.Instance.html#mk_meth_spec_prags"><span class="hs-identifier hs-var hs-var">mk_meth_spec_prags</span></a></span></span><span> </span><span id="local-6989586621681162672"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162672"><span class="hs-identifier hs-var">meth_id</span></a></span></span><span> </span><span id="local-6989586621681162671"><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162671"><span class="hs-identifier hs-var">spec_inst_prags</span></a></span></span><span> </span><span id="local-6989586621681162670"><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162670"><span class="hs-identifier hs-var">spec_prags_for_me</span></a></span></span><span>
</span><span id="line-1944"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Located TcSpecPrag] -&gt; TcSpecPrags
</span><a href="GHC.Hs.Binds.html#SpecPrags"><span class="hs-identifier hs-var">SpecPrags</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162670"><span class="hs-identifier hs-var">spec_prags_for_me</span></a></span><span> </span><span class="annot"><span class="annottext">[Located TcSpecPrag]
-&gt; [Located TcSpecPrag] -&gt; [Located TcSpecPrag]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162669"><span class="hs-identifier hs-var">spec_prags_from_inst</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1945"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1946"></span><span>    </span><span id="local-6989586621681162669"><span class="annot"><span class="annottext">spec_prags_from_inst :: [Located TcSpecPrag]
</span><a href="#local-6989586621681162669"><span class="hs-identifier hs-var hs-var">spec_prags_from_inst</span></a></span></span><span>
</span><span id="line-1947"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">InlinePragma -&gt; Bool
</span><a href="GHC.Types.Basic.html#isInlinePragma"><span class="hs-identifier hs-var">isInlinePragma</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; InlinePragma
</span><a href="GHC.Types.Id.html#idInlinePragma"><span class="hs-identifier hs-var">idInlinePragma</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162672"><span class="hs-identifier hs-var">meth_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1948"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>  </span><span class="hs-comment">-- Do not inherit SPECIALISE from the instance if the</span><span>
</span><span id="line-1949"></span><span>             </span><span class="hs-comment">-- method is marked INLINE, because then it'll be inlined</span><span>
</span><span id="line-1950"></span><span>             </span><span class="hs-comment">-- and the specialisation would do nothing. (Indeed it'll provoke</span><span>
</span><span id="line-1951"></span><span>             </span><span class="hs-comment">-- a warning from the desugarer</span><span>
</span><span id="line-1952"></span><span>       </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1953"></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TcSpecPrag -&gt; Located TcSpecPrag
forall l e. l -&gt; e -&gt; GenLocated l e
</span><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-var">L</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162666"><span class="hs-identifier hs-var">inst_loc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; HsWrapper -&gt; InlinePragma -&gt; TcSpecPrag
</span><a href="GHC.Hs.Binds.html#SpecPrag"><span class="hs-identifier hs-var">SpecPrag</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162672"><span class="hs-identifier hs-var">meth_id</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162664"><span class="hs-identifier hs-var">wrap</span></a></span><span> </span><span class="annot"><span class="annottext">InlinePragma
</span><a href="#local-6989586621681162663"><span class="hs-identifier hs-var">inl</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1954"></span><span>         </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#L"><span class="hs-identifier hs-type">L</span></a></span><span> </span><span id="local-6989586621681162666"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681162666"><span class="hs-identifier hs-var">inst_loc</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#SpecPrag"><span class="hs-identifier hs-type">SpecPrag</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span>       </span><span id="local-6989586621681162664"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162664"><span class="hs-identifier hs-var">wrap</span></a></span></span><span> </span><span id="local-6989586621681162663"><span class="annot"><span class="annottext">InlinePragma
</span><a href="#local-6989586621681162663"><span class="hs-identifier hs-var">inl</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162671"><span class="hs-identifier hs-var">spec_inst_prags</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1955"></span><span>
</span><span id="line-1956"></span><span>
</span><span id="line-1957"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#mkDefMethBind"><span class="hs-identifier hs-type">mkDefMethBind</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#DFunId"><span class="hs-identifier hs-type">DFunId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>
</span><span id="line-1958"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBind"><span class="hs-identifier hs-type">LHsBind</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Hs.Binds.html#LSig"><span class="hs-identifier hs-type">LSig</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1959"></span><span class="hs-comment">-- The is a default method (vanailla or generic) defined in the class</span><span>
</span><span id="line-1960"></span><span class="hs-comment">-- So make a binding   op = $dmop @t1 @t2</span><span>
</span><span id="line-1961"></span><span class="hs-comment">-- where $dmop is the name of the default method in the class,</span><span>
</span><span id="line-1962"></span><span class="hs-comment">-- and t1,t2 are the instance types.</span><span>
</span><span id="line-1963"></span><span class="hs-comment">-- See Note [Default methods in instances] for why we use</span><span>
</span><span id="line-1964"></span><span class="hs-comment">-- visible type application here</span><span>
</span><span id="line-1965"></span><span id="mkDefMethBind"><span class="annot"><span class="annottext">mkDefMethBind :: Id
-&gt; Class
-&gt; Id
-&gt; Name
-&gt; TcM
     (GenLocated
        SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)),
      [LSig (GhcPass 'Renamed)])
</span><a href="GHC.Tc.TyCl.Instance.html#mkDefMethBind"><span class="hs-identifier hs-var hs-var">mkDefMethBind</span></a></span></span><span> </span><span id="local-6989586621681162662"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162662"><span class="hs-identifier hs-var">dfun_id</span></a></span></span><span> </span><span id="local-6989586621681162661"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162661"><span class="hs-identifier hs-var">clas</span></a></span></span><span> </span><span id="local-6989586621681162660"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162660"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span> </span><span id="local-6989586621681162659"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162659"><span class="hs-identifier hs-var">dm_name</span></a></span></span><span>
</span><span id="line-1966"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681162658"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681162658"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) DynFlags
forall (m :: * -&gt; *). HasDynFlags m =&gt; m DynFlags
</span><a href="GHC.Driver.Session.html#getDynFlags"><span class="hs-identifier hs-var">getDynFlags</span></a></span><span>
</span><span id="line-1967"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162657"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162657"><span class="hs-identifier hs-var">dm_id</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Name -&gt; TcM Id
</span><a href="GHC.Tc.Utils.Env.html#tcLookupId"><span class="hs-identifier hs-var">tcLookupId</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681162659"><span class="hs-identifier hs-var">dm_name</span></a></span><span>
</span><span id="line-1968"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681162655"><span class="annot"><span class="annottext">inline_prag :: InlinePragma
</span><a href="#local-6989586621681162655"><span class="hs-identifier hs-var hs-var">inline_prag</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Id -&gt; InlinePragma
</span><a href="GHC.Types.Id.html#idInlinePragma"><span class="hs-identifier hs-var">idInlinePragma</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162657"><span class="hs-identifier hs-var">dm_id</span></a></span><span>
</span><span id="line-1969"></span><span>              </span><span id="local-6989586621681162654"><span class="annot"><span class="annottext">inline_prags :: [LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162654"><span class="hs-identifier hs-var hs-var">inline_prags</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">InlinePragma -&gt; Bool
</span><a href="GHC.Types.Basic.html#isAnyInlinePragma"><span class="hs-identifier hs-var">isAnyInlinePragma</span></a></span><span> </span><span class="annot"><span class="annottext">InlinePragma
</span><a href="#local-6989586621681162655"><span class="hs-identifier hs-var">inline_prag</span></a></span><span>
</span><span id="line-1970"></span><span>                           </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Sig (GhcPass 'Renamed) -&gt; LSig (GhcPass 'Renamed)
forall e. e -&gt; Located e
</span><a href="GHC.Types.SrcLoc.html#noLoc"><span class="hs-identifier hs-var">noLoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XInlineSig (GhcPass 'Renamed)
-&gt; Located (IdP (GhcPass 'Renamed))
-&gt; InlinePragma
-&gt; Sig (GhcPass 'Renamed)
forall pass.
XInlineSig pass -&gt; Located (IdP pass) -&gt; InlinePragma -&gt; Sig pass
</span><a href="GHC.Hs.Binds.html#InlineSig"><span class="hs-identifier hs-var">InlineSig</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XInlineSig (GhcPass 'Renamed)
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name
Located (IdP (GhcPass 'Renamed))
</span><a href="#local-6989586621681162651"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">InlinePragma
</span><a href="#local-6989586621681162655"><span class="hs-identifier hs-var">inline_prag</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-1971"></span><span>                           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-1972"></span><span>                           </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-1973"></span><span>                 </span><span class="hs-comment">-- Copy the inline pragma (if any) from the default method</span><span>
</span><span id="line-1974"></span><span>                 </span><span class="hs-comment">-- to this version. Note [INLINE and default methods]</span><span>
</span><span id="line-1975"></span><span>
</span><span id="line-1976"></span><span>              </span><span id="local-6989586621681162651"><span class="annot"><span class="annottext">fn :: GenLocated SrcSpan Name
</span><a href="#local-6989586621681162651"><span class="hs-identifier hs-var hs-var">fn</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Name -&gt; GenLocated SrcSpan Name
forall e. e -&gt; Located e
</span><a href="GHC.Types.SrcLoc.html#noLoc"><span class="hs-identifier hs-var">noLoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Name
</span><a href="GHC.Types.Id.html#idName"><span class="hs-identifier hs-var">idName</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162660"><span class="hs-identifier hs-var">sel_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1977"></span><span>              </span><span id="local-6989586621681162650"><span class="annot"><span class="annottext">visible_inst_tys :: [PredType]
</span><a href="#local-6989586621681162650"><span class="hs-identifier hs-var hs-var">visible_inst_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162649"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681162648"><span class="annot"><span class="annottext">TyConBinder
</span><a href="#local-6989586621681162648"><span class="hs-identifier hs-var">tcb</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162649"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162649"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [TyConBinder]
</span><a href="GHC.Core.TyCon.html#tyConBinders"><span class="hs-identifier hs-var hs-var">tyConBinders</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; TyCon
</span><a href="GHC.Core.Class.html#classTyCon"><span class="hs-identifier hs-var hs-var">classTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162661"><span class="hs-identifier hs-var">clas</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[TyConBinder] -&gt; [PredType] -&gt; [(TyConBinder, PredType)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-operator hs-var">`zip`</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162647"><span class="hs-identifier hs-var">inst_tys</span></a></span><span>
</span><span id="line-1978"></span><span>                                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyConBinder -&gt; ArgFlag
</span><a href="GHC.Core.TyCon.html#tyConBinderArgFlag"><span class="hs-identifier hs-var">tyConBinderArgFlag</span></a></span><span> </span><span class="annot"><span class="annottext">TyConBinder
</span><a href="#local-6989586621681162648"><span class="hs-identifier hs-var">tcb</span></a></span><span> </span><span class="annot"><span class="annottext">ArgFlag -&gt; ArgFlag -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">ArgFlag
</span><a href="GHC.Types.Var.html#Inferred"><span class="hs-identifier hs-var">Inferred</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-1979"></span><span>              </span><span id="local-6989586621681162644"><span class="annot"><span class="annottext">rhs :: LHsExpr (GhcPass 'Renamed)
</span><a href="#local-6989586621681162644"><span class="hs-identifier hs-var hs-var">rhs</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(LHsExpr (GhcPass 'Renamed)
 -&gt; PredType -&gt; LHsExpr (GhcPass 'Renamed))
-&gt; LHsExpr (GhcPass 'Renamed)
-&gt; [PredType]
-&gt; LHsExpr (GhcPass 'Renamed)
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="annot"><span class="annottext">LHsExpr (GhcPass 'Renamed)
-&gt; PredType -&gt; LHsExpr (GhcPass 'Renamed)
</span><a href="#local-6989586621681162643"><span class="hs-identifier hs-var">mk_vta</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">IdP (GhcPass 'Renamed) -&gt; LHsExpr (GhcPass 'Renamed)
forall (id :: Pass). IdP (GhcPass id) -&gt; LHsExpr (GhcPass id)
</span><a href="GHC.Hs.Utils.html#nlHsVar"><span class="hs-identifier hs-var">nlHsVar</span></a></span><span> </span><span class="annot"><span class="annottext">Name
IdP (GhcPass 'Renamed)
</span><a href="#local-6989586621681162659"><span class="hs-identifier hs-var">dm_name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162650"><span class="hs-identifier hs-var">visible_inst_tys</span></a></span><span>
</span><span id="line-1980"></span><span>              </span><span id="local-6989586621681162641"><span class="annot"><span class="annottext">bind :: GenLocated SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
</span><a href="#local-6989586621681162641"><span class="hs-identifier hs-var hs-var">bind</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)
-&gt; GenLocated
     SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
forall e. e -&gt; Located e
</span><a href="GHC.Types.SrcLoc.html#noLoc"><span class="hs-identifier hs-var">noLoc</span></a></span><span> </span><span class="annot"><span class="annottext">(HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)
 -&gt; GenLocated
      SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)))
-&gt; HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)
-&gt; GenLocated
     SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Origin
-&gt; GenLocated SrcSpan Name
-&gt; [LMatch (GhcPass 'Renamed) (LHsExpr (GhcPass 'Renamed))]
-&gt; HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)
</span><a href="GHC.Hs.Utils.html#mkTopFunBind"><span class="hs-identifier hs-var">mkTopFunBind</span></a></span><span> </span><span class="annot"><span class="annottext">Origin
</span><a href="GHC.Types.Basic.html#Generated"><span class="hs-identifier hs-var">Generated</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name
</span><a href="#local-6989586621681162651"><span class="hs-identifier hs-var">fn</span></a></span><span> </span><span class="annot"><span class="annottext">([LMatch (GhcPass 'Renamed) (LHsExpr (GhcPass 'Renamed))]
 -&gt; HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
-&gt; [LMatch (GhcPass 'Renamed) (LHsExpr (GhcPass 'Renamed))]
-&gt; HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-1981"></span><span>                             </span><span class="hs-special">[</span><span class="annot"><span class="annottext">HsMatchContext (NoGhcTc (GhcPass 'Renamed))
-&gt; [LPat (GhcPass 'Renamed)]
-&gt; LHsExpr (GhcPass 'Renamed)
-&gt; LMatch (GhcPass 'Renamed) (LHsExpr (GhcPass 'Renamed))
forall (p :: Pass) (body :: * -&gt; *).
HsMatchContext (NoGhcTc (GhcPass p))
-&gt; [LPat (GhcPass p)]
-&gt; Located (body (GhcPass p))
-&gt; LMatch (GhcPass p) (Located (body (GhcPass p)))
</span><a href="GHC.Hs.Utils.html#mkSimpleMatch"><span class="hs-identifier hs-var">mkSimpleMatch</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Located (IdP (GhcPass 'Renamed))
-&gt; HsMatchContext (GhcPass 'Renamed)
forall p. LIdP p -&gt; HsMatchContext p
</span><a href="GHC.Hs.Utils.html#mkPrefixFunRhs"><span class="hs-identifier hs-var">mkPrefixFunRhs</span></a></span><span> </span><span class="annot"><span class="annottext">GenLocated SrcSpan Name
Located (IdP (GhcPass 'Renamed))
</span><a href="#local-6989586621681162651"><span class="hs-identifier hs-var">fn</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">LHsExpr (GhcPass 'Renamed)
</span><a href="#local-6989586621681162644"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1982"></span><span>
</span><span id="line-1983"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">IO () -&gt; TcRn ()
forall (m :: * -&gt; *) a. MonadIO m =&gt; IO a -&gt; m a
</span><a href="../../base/src/Control.Monad.IO.Class.html#liftIO"><span class="hs-identifier hs-var">liftIO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DynFlags -&gt; DumpFlag -&gt; String -&gt; DumpFormat -&gt; SDoc -&gt; IO ()
</span><a href="GHC.Utils.Error.html#dumpIfSet_dyn"><span class="hs-identifier hs-var">dumpIfSet_dyn</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681162658"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">DumpFlag
</span><a href="GHC.Driver.Flags.html#Opt_D_dump_deriv"><span class="hs-identifier hs-var">Opt_D_dump_deriv</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Filling in method body&quot;</span></span><span>
</span><span id="line-1984"></span><span>                   </span><span class="annot"><span class="annottext">DumpFormat
</span><a href="GHC.Utils.Error.html#FormatHaskell"><span class="hs-identifier hs-var">FormatHaskell</span></a></span><span>
</span><span id="line-1985"></span><span>                   </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Class -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162661"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162647"><span class="hs-identifier hs-var">inst_tys</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-1986"></span><span>                          </span><span class="annot"><span class="annottext">ConTag -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162660"><span class="hs-identifier hs-var">sel_id</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#equals"><span class="hs-identifier hs-var">equals</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">LHsExpr (GhcPass 'Renamed) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">LHsExpr (GhcPass 'Renamed)
</span><a href="#local-6989586621681162644"><span class="hs-identifier hs-var">rhs</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1987"></span><span>
</span><span id="line-1988"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(GenLocated
   SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)),
 [LSig (GhcPass 'Renamed)])
-&gt; TcM
     (GenLocated
        SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed)),
      [LSig (GhcPass 'Renamed)])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenLocated SrcSpan (HsBindLR (GhcPass 'Renamed) (GhcPass 'Renamed))
</span><a href="#local-6989586621681162641"><span class="hs-identifier hs-var">bind</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162654"><span class="hs-identifier hs-var">inline_prags</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1989"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-1990"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Class
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681162647"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162647"><span class="hs-identifier hs-var">inst_tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; ([Id], [PredType], Class, [PredType])
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitDFunTy"><span class="hs-identifier hs-var">tcSplitDFunTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162662"><span class="hs-identifier hs-var">dfun_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-1991"></span><span>
</span><span id="line-1992"></span><span>    </span><span class="annot"><a href="#local-6989586621681162643"><span class="hs-identifier hs-type">mk_vta</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#LHsExpr"><span class="hs-identifier hs-type">LHsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Expr.html#LHsExpr"><span class="hs-identifier hs-type">LHsExpr</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span>
</span><span id="line-1993"></span><span>    </span><span id="local-6989586621681162643"><span class="annot"><span class="annottext">mk_vta :: LHsExpr (GhcPass 'Renamed)
-&gt; PredType -&gt; LHsExpr (GhcPass 'Renamed)
</span><a href="#local-6989586621681162643"><span class="hs-identifier hs-var hs-var">mk_vta</span></a></span></span><span> </span><span id="local-6989586621681162630"><span class="annot"><span class="annottext">LHsExpr (GhcPass 'Renamed)
</span><a href="#local-6989586621681162630"><span class="hs-identifier hs-var">fun</span></a></span></span><span> </span><span id="local-6989586621681162629"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162629"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">HsExpr (GhcPass 'Renamed) -&gt; LHsExpr (GhcPass 'Renamed)
forall e. e -&gt; Located e
</span><a href="GHC.Types.SrcLoc.html#noLoc"><span class="hs-identifier hs-var">noLoc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">XAppTypeE (GhcPass 'Renamed)
-&gt; LHsExpr (GhcPass 'Renamed)
-&gt; LHsWcType (NoGhcTc (GhcPass 'Renamed))
-&gt; HsExpr (GhcPass 'Renamed)
forall p.
XAppTypeE p -&gt; LHsExpr p -&gt; LHsWcType (NoGhcTc p) -&gt; HsExpr p
</span><a href="GHC.Hs.Expr.html#HsAppType"><span class="hs-identifier hs-var">HsAppType</span></a></span><span> </span><span class="annot"><span class="annottext">NoExtField
XAppTypeE (GhcPass 'Renamed)
</span><a href="GHC.Hs.Extension.html#noExtField"><span class="hs-identifier hs-var">noExtField</span></a></span><span> </span><span class="annot"><span class="annottext">LHsExpr (GhcPass 'Renamed)
</span><a href="#local-6989586621681162630"><span class="hs-identifier hs-var">fun</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsType (GhcPass 'Renamed)
-&gt; HsWildCardBndrs (GhcPass 'Renamed) (LHsType (GhcPass 'Renamed))
forall thing. thing -&gt; HsWildCardBndrs (GhcPass 'Renamed) thing
</span><a href="GHC.Hs.Type.html#mkEmptyWildCardBndrs"><span class="hs-identifier hs-var">mkEmptyWildCardBndrs</span></a></span><span> </span><span class="annot"><span class="annottext">(LHsType (GhcPass 'Renamed)
 -&gt; HsWildCardBndrs (GhcPass 'Renamed) (LHsType (GhcPass 'Renamed)))
-&gt; LHsType (GhcPass 'Renamed)
-&gt; HsWildCardBndrs (GhcPass 'Renamed) (LHsType (GhcPass 'Renamed))
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">LHsType (GhcPass 'Renamed) -&gt; LHsType (GhcPass 'Renamed)
forall (p :: Pass). LHsType (GhcPass p) -&gt; LHsType (GhcPass p)
</span><a href="GHC.Hs.Utils.html#nlHsParTy"><span class="hs-identifier hs-var">nlHsParTy</span></a></span><span>
</span><span id="line-1994"></span><span>                                                </span><span class="annot"><span class="annottext">(LHsType (GhcPass 'Renamed) -&gt; LHsType (GhcPass 'Renamed))
-&gt; LHsType (GhcPass 'Renamed) -&gt; LHsType (GhcPass 'Renamed)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">HsType (GhcPass 'Renamed) -&gt; LHsType (GhcPass 'Renamed)
forall e. e -&gt; Located e
</span><a href="GHC.Types.SrcLoc.html#noLoc"><span class="hs-identifier hs-var">noLoc</span></a></span><span> </span><span class="annot"><span class="annottext">(HsType (GhcPass 'Renamed) -&gt; LHsType (GhcPass 'Renamed))
-&gt; HsType (GhcPass 'Renamed) -&gt; LHsType (GhcPass 'Renamed)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">XXType (GhcPass 'Renamed) -&gt; HsType (GhcPass 'Renamed)
forall pass. XXType pass -&gt; HsType pass
</span><a href="GHC.Hs.Type.html#XHsType"><span class="hs-identifier hs-var">XHsType</span></a></span><span> </span><span class="annot"><span class="annottext">(XXType (GhcPass 'Renamed) -&gt; HsType (GhcPass 'Renamed))
-&gt; XXType (GhcPass 'Renamed) -&gt; HsType (GhcPass 'Renamed)
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">PredType -&gt; NewHsTypeX
</span><a href="GHC.Hs.Type.html#NHsCoreTy"><span class="hs-identifier hs-var">NHsCoreTy</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162629"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-1995"></span><span>       </span><span class="hs-comment">-- NB: use visible type application</span><span>
</span><span id="line-1996"></span><span>       </span><span class="hs-comment">-- See Note [Default methods in instances]</span><span>
</span><span id="line-1997"></span><span>
</span><span id="line-1998"></span><span class="hs-comment">----------------------</span><span>
</span><span id="line-1999"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#derivBindCtxt"><span class="hs-identifier hs-type">derivBindCtxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2000"></span><span id="derivBindCtxt"><span class="annot"><span class="annottext">derivBindCtxt :: Id -&gt; Class -&gt; [PredType] -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#derivBindCtxt"><span class="hs-identifier hs-var hs-var">derivBindCtxt</span></a></span></span><span> </span><span id="local-6989586621681162623"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162623"><span class="hs-identifier hs-var">sel_id</span></a></span></span><span> </span><span id="local-6989586621681162622"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162622"><span class="hs-identifier hs-var">clas</span></a></span></span><span> </span><span id="local-6989586621681162621"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162621"><span class="hs-identifier hs-var">tys</span></a></span></span><span>
</span><span id="line-2001"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;When typechecking the code for&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162623"><span class="hs-identifier hs-var">sel_id</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2002"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ConTag -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;in a derived instance for&quot;</span></span><span>
</span><span id="line-2003"></span><span>                    </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; [PredType] -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprClassPred"><span class="hs-identifier hs-var">pprClassPred</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162622"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162621"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="GHC.Utils.Outputable.html#colon"><span class="hs-identifier hs-var">colon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2004"></span><span>          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ConTag -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;To see the code I am typechecking, use -ddump-deriv&quot;</span></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-2005"></span><span>
</span><span id="line-2006"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#warnUnsatisfiedMinimalDefinition"><span class="hs-identifier hs-type">warnUnsatisfiedMinimalDefinition</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#ClassMinimalDef"><span class="hs-identifier hs-type">ClassMinimalDef</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-2007"></span><span id="warnUnsatisfiedMinimalDefinition"><span class="annot"><span class="annottext">warnUnsatisfiedMinimalDefinition :: BooleanFormula Name -&gt; TcRn ()
</span><a href="GHC.Tc.TyCl.Instance.html#warnUnsatisfiedMinimalDefinition"><span class="hs-identifier hs-var hs-var">warnUnsatisfiedMinimalDefinition</span></a></span></span><span> </span><span id="local-6989586621681162616"><span class="annot"><span class="annottext">BooleanFormula Name
</span><a href="#local-6989586621681162616"><span class="hs-identifier hs-var">mindef</span></a></span></span><span>
</span><span id="line-2008"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681162615"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162615"><span class="hs-identifier hs-var">warn</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">WarningFlag -&gt; TcRn Bool
forall gbl lcl. WarningFlag -&gt; TcRnIf gbl lcl Bool
</span><a href="GHC.Tc.Utils.Monad.html#woptM"><span class="hs-identifier hs-var">woptM</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnMissingMethods"><span class="hs-identifier hs-var">Opt_WarnMissingMethods</span></a></span><span>
</span><span id="line-2009"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">WarnReason -&gt; Bool -&gt; SDoc -&gt; TcRn ()
</span><a href="GHC.Tc.Utils.Monad.html#warnTc"><span class="hs-identifier hs-var">warnTc</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WarningFlag -&gt; WarnReason
</span><a href="GHC.Driver.Flags.html#Reason"><span class="hs-identifier hs-var">Reason</span></a></span><span> </span><span class="annot"><span class="annottext">WarningFlag
</span><a href="GHC.Driver.Flags.html#Opt_WarnMissingMethods"><span class="hs-identifier hs-var">Opt_WarnMissingMethods</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681162615"><span class="hs-identifier hs-var">warn</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681162610"><span class="hs-identifier hs-var">message</span></a></span><span>
</span><span id="line-2010"></span><span>       </span><span class="hs-special">}</span><span>
</span><span id="line-2011"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2012"></span><span>    </span><span id="local-6989586621681162610"><span class="annot"><span class="annottext">message :: SDoc
</span><a href="#local-6989586621681162610"><span class="hs-identifier hs-var hs-var">message</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;No explicit implementation for&quot;</span></span><span>
</span><span id="line-2013"></span><span>                   </span><span class="hs-special">,</span><span class="annot"><span class="annottext">ConTag -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">BooleanFormula Name -&gt; SDoc
forall a. Outputable a =&gt; BooleanFormula a -&gt; SDoc
</span><a href="GHC.Data.BooleanFormula.html#pprBooleanFormulaNice"><span class="hs-identifier hs-var">pprBooleanFormulaNice</span></a></span><span> </span><span class="annot"><span class="annottext">BooleanFormula Name
</span><a href="#local-6989586621681162616"><span class="hs-identifier hs-var">mindef</span></a></span><span>
</span><span id="line-2014"></span><span>                   </span><span class="hs-special">]</span><span>
</span><span id="line-2015"></span><span>
</span><span id="line-2016"></span><span class="hs-comment">{-
Note [Export helper functions]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We arrange to export the &quot;helper functions&quot; of an instance declaration,
so that they are not subject to preInlineUnconditionally, even if their
RHS is trivial.  Reason: they are mentioned in the DFunUnfolding of
the dict fun as Ids, not as CoreExprs, so we can't substitute a
non-variable for them.

We could change this by making DFunUnfoldings have CoreExprs, but it
seems a bit simpler this way.

Note [Default methods in instances]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this

   class Baz v x where
      foo :: x -&gt; x
      foo y = &lt;blah&gt;

   instance Baz Int Int

From the class decl we get

   $dmfoo :: forall v x. Baz v x =&gt; x -&gt; x
   $dmfoo y = &lt;blah&gt;

Notice that the type is ambiguous.  So we use Visible Type Application
to disambiguate:

   $dBazIntInt = MkBaz fooIntInt
   fooIntInt = $dmfoo @Int @Int

Lacking VTA we'd get ambiguity errors involving the default method.  This applies
equally to vanilla default methods (#1061) and generic default methods
(#12220).

Historical note: before we had VTA we had to generate
post-type-checked code, which took a lot more code, and didn't work for
generic default methods.

Note [INLINE and default methods]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Default methods need special case.  They are supposed to behave rather like
macros.  For example

  class Foo a where
    op1, op2 :: Bool -&gt; a -&gt; a

    {-# INLINE op1 #-}
    op1 b x = op2 (not b) x

  instance Foo Int where
    -- op1 via default method
    op2 b x = &lt;blah&gt;

The instance declaration should behave

   just as if 'op1' had been defined with the
   code, and INLINE pragma, from its original
   definition.

That is, just as if you'd written

  instance Foo Int where
    op2 b x = &lt;blah&gt;

    {-# INLINE op1 #-}
    op1 b x = op2 (not b) x

So for the above example we generate:

  {-# INLINE $dmop1 #-}
  -- $dmop1 has an InlineCompulsory unfolding
  $dmop1 d b x = op2 d (not b) x

  $fFooInt = MkD $cop1 $cop2

  {-# INLINE $cop1 #-}
  $cop1 = $dmop1 $fFooInt

  $cop2 = &lt;blah&gt;

Note carefully:

* We *copy* any INLINE pragma from the default method $dmop1 to the
  instance $cop1.  Otherwise we'll just inline the former in the
  latter and stop, which isn't what the user expected

* Regardless of its pragma, we give the default method an
  unfolding with an InlineCompulsory source. That means
  that it'll be inlined at every use site, notably in
  each instance declaration, such as $cop1.  This inlining
  must happen even though
    a) $dmop1 is not saturated in $cop1
    b) $cop1 itself has an INLINE pragma

  It's vital that $dmop1 *is* inlined in this way, to allow the mutual
  recursion between $fooInt and $cop1 to be broken

* To communicate the need for an InlineCompulsory to the desugarer
  (which makes the Unfoldings), we use the IsDefaultMethod constructor
  in TcSpecPrags.


************************************************************************
*                                                                      *
        Specialise instance pragmas
*                                                                      *
************************************************************************

Note [SPECIALISE instance pragmas]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider

   instance (Ix a, Ix b) =&gt; Ix (a,b) where
     {-# SPECIALISE instance Ix (Int,Int) #-}
     range (x,y) = ...

We make a specialised version of the dictionary function, AND
specialised versions of each *method*.  Thus we should generate
something like this:

  $dfIxPair :: (Ix a, Ix b) =&gt; Ix (a,b)
  {-# DFUN [$crangePair, ...] #-}
  {-# SPECIALISE $dfIxPair :: Ix (Int,Int) #-}
  $dfIxPair da db = Ix ($crangePair da db) (...other methods...)

  $crange :: (Ix a, Ix b) -&gt; ((a,b),(a,b)) -&gt; [(a,b)]
  {-# SPECIALISE $crange :: ((Int,Int),(Int,Int)) -&gt; [(Int,Int)] #-}
  $crange da db = &lt;blah&gt;

The SPECIALISE pragmas are acted upon by the desugarer, which generate

  dii :: Ix Int
  dii = ...

  $s$dfIxPair :: Ix ((Int,Int),(Int,Int))
  {-# DFUN [$crangePair di di, ...] #-}
  $s$dfIxPair = Ix ($crangePair di di) (...)

  {-# RULE forall (d1,d2:Ix Int). $dfIxPair Int Int d1 d2 = $s$dfIxPair #-}

  $s$crangePair :: ((Int,Int),(Int,Int)) -&gt; [(Int,Int)]
  $c$crangePair = ...specialised RHS of $crangePair...

  {-# RULE forall (d1,d2:Ix Int). $crangePair Int Int d1 d2 = $s$crangePair #-}

Note that

  * The specialised dictionary $s$dfIxPair is very much needed, in case we
    call a function that takes a dictionary, but in a context where the
    specialised dictionary can be used.  See #7797.

  * The ClassOp rule for 'range' works equally well on $s$dfIxPair, because
    it still has a DFunUnfolding.  See Note [ClassOp/DFun selection]

  * A call (range ($dfIxPair Int Int d1 d2)) might simplify two ways:
       --&gt; {ClassOp rule for range}     $crangePair Int Int d1 d2
       --&gt; {SPEC rule for $crangePair}  $s$crangePair
    or thus:
       --&gt; {SPEC rule for $dfIxPair}    range $s$dfIxPair
       --&gt; {ClassOpRule for range}      $s$crangePair
    It doesn't matter which way.

  * We want to specialise the RHS of both $dfIxPair and $crangePair,
    but the SAME HsWrapper will do for both!  We can call tcSpecPrag
    just once, and pass the result (in spec_inst_info) to tcMethods.
-}</span><span>
</span><span id="line-2185"></span><span>
</span><span id="line-2186"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcSpecInstPrags"><span class="hs-identifier hs-type">tcSpecInstPrags</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#DFunId"><span class="hs-identifier hs-type">DFunId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstBindings"><span class="hs-identifier hs-type">InstBindings</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span>
</span><span id="line-2187"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.SrcLoc.html#Located"><span class="hs-identifier hs-type">Located</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#TcSpecPrag"><span class="hs-identifier hs-type">TcSpecPrag</span></a></span><span class="hs-special">]</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Gen.Sig.html#TcPragEnv"><span class="hs-identifier hs-type">TcPragEnv</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2188"></span><span id="tcSpecInstPrags"><span class="annot"><span class="annottext">tcSpecInstPrags :: Id
-&gt; InstBindings (GhcPass 'Renamed)
-&gt; TcM ([Located TcSpecPrag], TcPragEnv)
</span><a href="GHC.Tc.TyCl.Instance.html#tcSpecInstPrags"><span class="hs-identifier hs-var hs-var">tcSpecInstPrags</span></a></span></span><span> </span><span id="local-6989586621681162609"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162609"><span class="hs-identifier hs-var">dfun_id</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Utils.Env.html#InstBindings"><span class="hs-identifier hs-type">InstBindings</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ib_binds :: forall a. InstBindings a -&gt; LHsBinds a
</span><a href="GHC.Tc.Utils.Env.html#ib_binds"><span class="hs-identifier hs-var">ib_binds</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681162608"><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681162608"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ib_pragmas :: forall a. InstBindings a -&gt; [LSig a]
</span><a href="GHC.Tc.Utils.Env.html#ib_pragmas"><span class="hs-identifier hs-var">ib_pragmas</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681162607"><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162607"><span class="hs-identifier hs-var">uprags</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-2189"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681162606"><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162606"><span class="hs-identifier hs-var">spec_inst_prags</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(LSig (GhcPass 'Renamed)
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (Located TcSpecPrag))
-&gt; [LSig (GhcPass 'Renamed)] -&gt; TcM [Located TcSpecPrag]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="../../base/src/Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Sig (GhcPass 'Renamed) -&gt; TcM TcSpecPrag)
-&gt; LSig (GhcPass 'Renamed)
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (Located TcSpecPrag)
forall a b. (a -&gt; TcM b) -&gt; Located a -&gt; TcM (Located b)
</span><a href="GHC.Tc.Utils.Monad.html#wrapLocM"><span class="hs-identifier hs-var">wrapLocM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; Sig (GhcPass 'Renamed) -&gt; TcM TcSpecPrag
</span><a href="GHC.Tc.TyCl.Instance.html#tcSpecInst"><span class="hs-identifier hs-var">tcSpecInst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162609"><span class="hs-identifier hs-var">dfun_id</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([LSig (GhcPass 'Renamed)] -&gt; TcM [Located TcSpecPrag])
-&gt; [LSig (GhcPass 'Renamed)] -&gt; TcM [Located TcSpecPrag]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2190"></span><span>                            </span><span class="annot"><span class="annottext">(LSig (GhcPass 'Renamed) -&gt; Bool)
-&gt; [LSig (GhcPass 'Renamed)] -&gt; [LSig (GhcPass 'Renamed)]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">LSig (GhcPass 'Renamed) -&gt; Bool
forall name. LSig name -&gt; Bool
</span><a href="GHC.Hs.Binds.html#isSpecInstLSig"><span class="hs-identifier hs-var">isSpecInstLSig</span></a></span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162607"><span class="hs-identifier hs-var">uprags</span></a></span><span>
</span><span id="line-2191"></span><span>             </span><span class="hs-comment">-- The filter removes the pragmas for methods</span><span>
</span><span id="line-2192"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">([Located TcSpecPrag], TcPragEnv)
-&gt; TcM ([Located TcSpecPrag], TcPragEnv)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Located TcSpecPrag]
</span><a href="#local-6989586621681162606"><span class="hs-identifier hs-var">spec_inst_prags</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
-&gt; LHsBinds (GhcPass 'Renamed) -&gt; TcPragEnv
</span><a href="GHC.Tc.Gen.Sig.html#mkPragEnv"><span class="hs-identifier hs-var">mkPragEnv</span></a></span><span> </span><span class="annot"><span class="annottext">[LSig (GhcPass 'Renamed)]
</span><a href="#local-6989586621681162607"><span class="hs-identifier hs-var">uprags</span></a></span><span> </span><span class="annot"><span class="annottext">LHsBinds (GhcPass 'Renamed)
</span><a href="#local-6989586621681162608"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2193"></span><span>
</span><span id="line-2194"></span><span class="hs-comment">------------------------------</span><span>
</span><span id="line-2195"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcSpecInst"><span class="hs-identifier hs-type">tcSpecInst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Var.html#Id"><span class="hs-identifier hs-type">Id</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#Sig"><span class="hs-identifier hs-type">Sig</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Binds.html#TcSpecPrag"><span class="hs-identifier hs-type">TcSpecPrag</span></a></span><span>
</span><span id="line-2196"></span><span id="tcSpecInst"><span class="annot"><span class="annottext">tcSpecInst :: Id -&gt; Sig (GhcPass 'Renamed) -&gt; TcM TcSpecPrag
</span><a href="GHC.Tc.TyCl.Instance.html#tcSpecInst"><span class="hs-identifier hs-var hs-var">tcSpecInst</span></a></span></span><span> </span><span id="local-6989586621681162601"><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162601"><span class="hs-identifier hs-var">dfun_id</span></a></span></span><span> </span><span id="local-6989586621681162600"><span class="annot"><span class="annottext">prag :: Sig (GhcPass 'Renamed)
</span><a href="#local-6989586621681162600"><span class="hs-identifier hs-var">prag</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#SpecInstSig"><span class="hs-identifier hs-type">SpecInstSig</span></a></span><span> </span><span class="annot"><span class="annottext">XSpecInstSig (GhcPass 'Renamed)
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">SourceText
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681162598"><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681162598"><span class="hs-identifier hs-var">hs_ty</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-2197"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; TcM TcSpecPrag -&gt; TcM TcSpecPrag
forall a. SDoc -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Utils.Monad.html#addErrCtxt"><span class="hs-identifier hs-var">addErrCtxt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Sig (GhcPass 'Renamed) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="#local-6989586621681162597"><span class="hs-identifier hs-var">spec_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">Sig (GhcPass 'Renamed)
</span><a href="#local-6989586621681162600"><span class="hs-identifier hs-var">prag</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(TcM TcSpecPrag -&gt; TcM TcSpecPrag)
-&gt; TcM TcSpecPrag -&gt; TcM TcSpecPrag
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span>
</span><span id="line-2198"></span><span>    </span><span class="hs-keyword">do</span><span>  </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681162596"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162596"><span class="hs-identifier hs-var">spec_dfun_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; LHsSigType (GhcPass 'Renamed) -&gt; TcM PredType
</span><a href="GHC.Tc.Gen.HsType.html#tcHsClsInstType"><span class="hs-identifier hs-var">tcHsClsInstType</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#SpecInstCtxt"><span class="hs-identifier hs-var">SpecInstCtxt</span></a></span><span> </span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681162598"><span class="hs-identifier hs-var">hs_ty</span></a></span><span>
</span><span id="line-2199"></span><span>        </span><span class="hs-special">;</span><span> </span><span id="local-6989586621681162594"><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162594"><span class="hs-identifier hs-var">co_fn</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt -&gt; PredType -&gt; PredType -&gt; TcM HsWrapper
</span><a href="GHC.Tc.Gen.Sig.html#tcSpecWrapper"><span class="hs-identifier hs-var">tcSpecWrapper</span></a></span><span> </span><span class="annot"><span class="annottext">UserTypeCtxt
</span><a href="GHC.Tc.Types.Origin.html#SpecInstCtxt"><span class="hs-identifier hs-var">SpecInstCtxt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; PredType
</span><a href="GHC.Types.Id.html#idType"><span class="hs-identifier hs-var">idType</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162601"><span class="hs-identifier hs-var">dfun_id</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162596"><span class="hs-identifier hs-var">spec_dfun_ty</span></a></span><span>
</span><span id="line-2200"></span><span>        </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcSpecPrag -&gt; TcM TcSpecPrag
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Id -&gt; HsWrapper -&gt; InlinePragma -&gt; TcSpecPrag
</span><a href="GHC.Hs.Binds.html#SpecPrag"><span class="hs-identifier hs-var">SpecPrag</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><a href="#local-6989586621681162601"><span class="hs-identifier hs-var">dfun_id</span></a></span><span> </span><span class="annot"><span class="annottext">HsWrapper
</span><a href="#local-6989586621681162594"><span class="hs-identifier hs-var">co_fn</span></a></span><span> </span><span class="annot"><span class="annottext">InlinePragma
</span><a href="GHC.Types.Basic.html#defaultInlinePragma"><span class="hs-identifier hs-var">defaultInlinePragma</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-2201"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2202"></span><span>    </span><span id="local-6989586621681162597"><span class="annot"><span class="annottext">spec_ctxt :: a -&gt; SDoc
</span><a href="#local-6989586621681162597"><span class="hs-identifier hs-var hs-var">spec_ctxt</span></a></span></span><span> </span><span id="local-6989586621681162589"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681162589"><span class="hs-identifier hs-var">prag</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; ConTag -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;In the pragma:&quot;</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681162589"><span class="hs-identifier hs-var">prag</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2203"></span><span>
</span><span id="line-2204"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#tcSpecInst"><span class="hs-identifier hs-var">tcSpecInst</span></a></span><span> </span><span class="annot"><span class="annottext">Id
</span><span class="hs-identifier">_</span></span><span>  </span><span class="annot"><span class="annottext">Sig (GhcPass 'Renamed)
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; TcM TcSpecPrag
forall a. String -&gt; a
</span><a href="GHC.Utils.Panic.Plain.html#panic"><span class="hs-identifier hs-var">panic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;tcSpecInst&quot;</span></span><span>
</span><span id="line-2205"></span><span>
</span><span id="line-2206"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
\subsection{Error messages}
*                                                                      *
************************************************************************
-}</span><span>
</span><span id="line-2213"></span><span>
</span><span id="line-2214"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#instDeclCtxt1"><span class="hs-identifier hs-type">instDeclCtxt1</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Hs.Type.html#LHsSigType"><span class="hs-identifier hs-type">LHsSigType</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcRn"><span class="hs-identifier hs-type">GhcRn</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2215"></span><span id="instDeclCtxt1"><span class="annot"><span class="annottext">instDeclCtxt1 :: LHsSigType (GhcPass 'Renamed) -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#instDeclCtxt1"><span class="hs-identifier hs-var hs-var">instDeclCtxt1</span></a></span></span><span> </span><span id="local-6989586621681162587"><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681162587"><span class="hs-identifier hs-var">hs_inst_ty</span></a></span></span><span>
</span><span id="line-2216"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#inst_decl_ctxt"><span class="hs-identifier hs-var">inst_decl_ctxt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsType (GhcPass 'Renamed) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed) -&gt; LHsType (GhcPass 'Renamed)
forall (p :: Pass). LHsSigType (GhcPass p) -&gt; LHsType (GhcPass p)
</span><a href="GHC.Hs.Type.html#getLHsInstDeclHead"><span class="hs-identifier hs-var">getLHsInstDeclHead</span></a></span><span> </span><span class="annot"><span class="annottext">LHsSigType (GhcPass 'Renamed)
</span><a href="#local-6989586621681162587"><span class="hs-identifier hs-var">hs_inst_ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2217"></span><span>
</span><span id="line-2218"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#instDeclCtxt2"><span class="hs-identifier hs-type">instDeclCtxt2</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2219"></span><span id="instDeclCtxt2"><span class="annot"><span class="annottext">instDeclCtxt2 :: PredType -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#instDeclCtxt2"><span class="hs-identifier hs-var hs-var">instDeclCtxt2</span></a></span></span><span> </span><span id="local-6989586621681162584"><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162584"><span class="hs-identifier hs-var">dfun_ty</span></a></span></span><span>
</span><span id="line-2220"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#inst_decl_ctxt"><span class="hs-identifier hs-var">inst_decl_ctxt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PredType -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; [PredType] -&gt; PredType
</span><a href="GHC.Core.Predicate.html#mkClassPred"><span class="hs-identifier hs-var">mkClassPred</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162582"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162581"><span class="hs-identifier hs-var">tys</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-2221"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-2222"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Id]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span class="annot"><span class="annottext">[PredType]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621681162582"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681162582"><span class="hs-identifier hs-var">cls</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621681162581"><span class="annot"><span class="annottext">[PredType]
</span><a href="#local-6989586621681162581"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PredType -&gt; ([Id], [PredType], Class, [PredType])
</span><a href="GHC.Tc.Utils.TcType.html#tcSplitDFunTy"><span class="hs-identifier hs-var">tcSplitDFunTy</span></a></span><span> </span><span class="annot"><span class="annottext">PredType
</span><a href="#local-6989586621681162584"><span class="hs-identifier hs-var">dfun_ty</span></a></span><span>
</span><span id="line-2223"></span><span>
</span><span id="line-2224"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#inst_decl_ctxt"><span class="hs-identifier hs-type">inst_decl_ctxt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2225"></span><span id="inst_decl_ctxt"><span class="annot"><span class="annottext">inst_decl_ctxt :: SDoc -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#inst_decl_ctxt"><span class="hs-identifier hs-var hs-var">inst_decl_ctxt</span></a></span></span><span> </span><span id="local-6989586621681162580"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681162580"><span class="hs-identifier hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; ConTag -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;In the instance declaration for&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-2226"></span><span>                        </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681162580"><span class="hs-identifier hs-var">doc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2227"></span><span>
</span><span id="line-2228"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#badBootFamInstDeclErr"><span class="hs-identifier hs-type">badBootFamInstDeclErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2229"></span><span id="badBootFamInstDeclErr"><span class="annot"><span class="annottext">badBootFamInstDeclErr :: SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#badBootFamInstDeclErr"><span class="hs-identifier hs-var hs-var">badBootFamInstDeclErr</span></a></span></span><span>
</span><span id="line-2230"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Illegal family instance in hs-boot file&quot;</span></span><span>
</span><span id="line-2231"></span><span>
</span><span id="line-2232"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#notFamily"><span class="hs-identifier hs-type">notFamily</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2233"></span><span id="notFamily"><span class="annot"><span class="annottext">notFamily :: TyCon -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#notFamily"><span class="hs-identifier hs-var hs-var">notFamily</span></a></span></span><span> </span><span id="local-6989586621681162579"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681162579"><span class="hs-identifier hs-var">tycon</span></a></span></span><span>
</span><span id="line-2234"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Illegal family instance for&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681162579"><span class="hs-identifier hs-var">tycon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2235"></span><span>         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ConTag -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681162579"><span class="hs-identifier hs-var">tycon</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is not an indexed type family&quot;</span></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-2236"></span><span>
</span><span id="line-2237"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#assocInClassErr"><span class="hs-identifier hs-type">assocInClassErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2238"></span><span id="assocInClassErr"><span class="annot"><span class="annottext">assocInClassErr :: TyCon -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#assocInClassErr"><span class="hs-identifier hs-var hs-var">assocInClassErr</span></a></span></span><span> </span><span id="local-6989586621681162577"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681162577"><span class="hs-identifier hs-var">name</span></a></span></span><span>
</span><span id="line-2239"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Associated type&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681162577"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-2240"></span><span>   </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;must be inside a class instance&quot;</span></span><span>
</span><span id="line-2241"></span><span>
</span><span id="line-2242"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#badFamInstDecl"><span class="hs-identifier hs-type">badFamInstDecl</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2243"></span><span id="badFamInstDecl"><span class="annot"><span class="annottext">badFamInstDecl :: TyCon -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#badFamInstDecl"><span class="hs-identifier hs-var hs-var">badFamInstDecl</span></a></span></span><span> </span><span id="local-6989586621681162576"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681162576"><span class="hs-identifier hs-var">tc_name</span></a></span></span><span>
</span><span id="line-2244"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Illegal family instance for&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-2245"></span><span>           </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681162576"><span class="hs-identifier hs-var">tc_name</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2246"></span><span>         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ConTag -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#nest"><span class="hs-identifier hs-var">nest</span></a></span><span> </span><span class="annot"><span class="annottext">ConTag
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#parens"><span class="hs-identifier hs-var">parens</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; SDoc) -&gt; SDoc -&gt; SDoc
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Use TypeFamilies to allow indexed type families&quot;</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-2247"></span><span>
</span><span id="line-2248"></span><span class="annot"><a href="GHC.Tc.TyCl.Instance.html#notOpenFamily"><span class="hs-identifier hs-type">notOpenFamily</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-2249"></span><span id="notOpenFamily"><span class="annot"><span class="annottext">notOpenFamily :: TyCon -&gt; SDoc
</span><a href="GHC.Tc.TyCl.Instance.html#notOpenFamily"><span class="hs-identifier hs-var hs-var">notOpenFamily</span></a></span></span><span> </span><span id="local-6989586621681162575"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681162575"><span class="hs-identifier hs-var">tc</span></a></span></span><span>
</span><span id="line-2250"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Illegal instance for closed family&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681162575"><span class="hs-identifier hs-var">tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-2251"></span></pre></body></html>